QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#279609 | #5303. No Bug No Game | zzuqy# | WA | 32ms | 74636kb | C++11 | 1.0kb | 2023-12-08 22:04:58 | 2023-12-08 22:04:59 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int read()
{
int x;cin>>x;
return x;
}
int n,k,p[3010];
int w[3010][12],f[3010][3010],g[3010][3010],sum;
int main()
{
// freopen("1.in","r",stdin);
for(int i=0;i<3010;i++)
for(int j=0;j<3010;j++)
f[i][j]=g[i][j]=-5e8;
n=read();k=read();
for(int i=1;i<=n;i++)
{
p[i]=read();
for(int j=1;j<=p[i];j++)
w[i][j]=read();
sum+=p[i];
}
if(sum<=k)
{
int ans=0;
for(int i=1;i<=n;i++)
ans=ans+w[i][p[i]];
cout<<ans;
return 0;
}
int ans=0;
for(int i=1;i<=n;i++){
f[i-1][0]=0;
for(int j=0;j+p[i]<=3000;j++)
f[i][j+p[i]]=max(f[i-1][j+p[i]],f[i-1][j]+w[i][p[i]]);
}
for(int i=n;i>=1;i--){
g[i+1][0]=0;
for(int j=0;j+p[i]<=3000;j++)
g[i][j+p[i]]=max(g[i+1][j+p[i]],g[i+1][j]+w[i][p[i]]);
}
for(int i=1;i<=n;i++)
for(int x=1;x<=p[i];x++)
for(int y=0;x+y<=k;y++)
ans=max(ans,w[i][x]+f[i-1][k-x-y]+g[i+1][y]);
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 74492kb
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: 32ms
memory: 74636kb
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:
68231163
result:
wrong answer 1st numbers differ - expected: '68279788', found: '68231163'