Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
145414 | 冼俊烨 | 收益 | C++ | 通过 | 100 | 3 MS | 4160 KB | 713 | 2024-05-05 08:07:27 |
#include <bits/stdc++.h> using namespace std; int T,amount,n,d; int weight[12],profit[12],dp[1000002]; int main() { //freopen("Profit.in","r",stdin); //freopen("Profit.out","w",stdout); scanf("%d",&T); while(T--) { memset(dp,0,sizeof(dp)); scanf("%d%d%d",&amount,&n,&d); for (int i=0; i<d; i++) { scanf("%d%d",&weight[i],&profit[i]); weight[i] /= 1000; } for (int i=0; i<n; i++) { int t = amount/1000; for (int j=0; j<d; j++) for (int k=weight[j]; k<=t; k++) dp[k]=max(dp[k],dp[k-weight[j]]+profit[j]); amount += dp[t]; } printf("%d\n",amount); } return 0; } //C