QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105871 | #5303. No Bug No Game | 1935Zz | WA | 70ms | 74604kb | C++14 | 1.7kb | 2023-05-15 19:35:48 | 2023-05-15 19:35:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define pii pair<int, int>
#define endl '\n'
#define all(a) a.begin(), a.end()
const int maxi = 2e5 + 10;
int dp[3020][3020][2],p[3010],w[3010][11];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >>t;
while (t--)
{
int n, k;
cin >> n >> k;
for (int i = 1; i <= n;i++){
cin >> p[i];
for (int j = 1; j <= p[i];j++){
cin >> w[i][j];
}
}
int ans = 0;
memset(dp, -1, sizeof(dp));
dp[0][0][0] = 0;
for (int i = 0; i < n;i++){
memcpy(dp[i+1], dp[i], sizeof(dp[i]));
for (int j = 0; j < k;j++){
if(dp[i][j][0]!=-1){
if(j+p[i+1]<=k)
dp[i + 1][j + p[i + 1]][0] = max(dp[i + 1][j + p[i + 1]][0], dp[i][j][0] + w[i + 1][p[i + 1]]);
for (int q = 1; q < p[i + 1];q++){
dp[i+1][j+p[i+1]][1]=max(dp[i+1][j+p[i+1]][1], dp[i][j][0] + w[i + 1][q]);
}
}
if(dp[i][j][1]!=-1){
dp[i + 1][j + p[i+1]][1] = max(dp[i + 1][j + p[i+1]][1], dp[i][j][1] + w[i + 1][p[i + 1]]);
}
}
}
// cout << dp[3][4][1] << endl;
for (int i = 0; i <= k; i++)
{
ans = max(ans, dp[n][i][0]);
}
for (int i = k+1; i <= k+10; i++)
{
ans = max(ans, dp[n][i][1]);
}
cout << ans << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 12ms
memory: 74504kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Wrong Answer
time: 70ms
memory: 74604kb
input:
3000 3000 10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159 4 18007 33590 80674 91139 4 10304 31694 70745 50656 10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658 8 95640 66120 87735 36388 44046 92415 6952 94772 9 60565 27904 98726 87052 35768 25453 14563 34273 92501 10 66332...
output:
68324227
result:
wrong answer 1st numbers differ - expected: '68279788', found: '68324227'