QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#279605 | #5303. No Bug No Game | zzuqy# | WA | 21ms | 74480kb | C++11 | 921b | 2023-12-08 21:57:14 | 2023-12-08 21:57:15 |
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);
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++)
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--)
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3844kb
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: 21ms
memory: 74480kb
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:
68235226
result:
wrong answer 1st numbers differ - expected: '68279788', found: '68235226'