标签:而且 std line 其他 max pre efi i++ 相互
#include <bits/stdc++.h>
#define REP(i,a,b) for (int i=(a); i<(b); i++)
using namespace std;
const int maxn = 6010;
int n, k;
int card[maxn], fav[510], joy[15];
int dp[520][maxn];
int f[100010], c[100010];
int main()
{
scanf("%d%d", &n, &k);
int tot = n * k;
REP(i, 0, tot) {
scanf("%d", &card[i]);
c[card[i]]++;
}
REP(i, 0, n) {
scanf("%d", &fav[i]);
f[fav[i]]++;
}
REP(i, 1, k+1) scanf("%d", &joy[i]);
REP(x, 0, n) REP(y, 0, tot) REP(i, 0, k+1) {
dp[x+1][y+i] = max(dp[x+1][y+i], dp[x][y] + joy[i]);
}
int ans = 0;
REP(i, 0, 100010) {
if (f[i] != 0)
ans += dp[f[i]][c[i]];
}
printf("%d\n", ans);
return 0;
}
Codeforces Round #490(Div.3) F
标签:而且 std line 其他 max pre efi i++ 相互
原文地址:https://www.cnblogs.com/RFisher/p/9222178.html