#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500;
int n,m,k;
int b[MAXN];
int v[MAXN];
int dp[MAXN][MAXN];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m >> k;
for(int i=0;i<n;i++) cin >> v[i];
for(int i=0;i<=m;i++) cin >> b[i];
for(int i=0;i<n;i++){
for(int t=0;t<=k;t++){
//cout<<dp[i][t]<<" ";
for(int j=0;j + v[i] <= m && j <= t;j++){
dp[i+1][t-j] = max(dp[i+1][t - j], dp[i][t] + b[v[i] + j] );
}
}//cout<<endl;
}
int rs = 0;
for(int i=0;i<=m;i++) rs = max(rs,dp[n][i]);
// cout<<i<<": "<<dp[n][i]<<'\n';
cout<<rs<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
1280 KB |
Output is correct |
2 |
Execution timed out |
1063 ms |
940 KB |
Time limit exceeded |
3 |
Incorrect |
88 ms |
1272 KB |
Output isn't correct |
4 |
Correct |
68 ms |
1328 KB |
Output is correct |
5 |
Correct |
108 ms |
1272 KB |
Output is correct |
6 |
Correct |
64 ms |
1272 KB |
Output is correct |
7 |
Correct |
74 ms |
1308 KB |
Output is correct |
8 |
Correct |
78 ms |
1400 KB |
Output is correct |
9 |
Correct |
78 ms |
1244 KB |
Output is correct |
10 |
Execution timed out |
1082 ms |
860 KB |
Time limit exceeded |