QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#587490 | #5303. No Bug No Game | xiaofanger | WA | 45ms | 3924kb | C++17 | 1.0kb | 2024-09-24 20:17:03 | 2024-09-24 20:17:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
int x=0,f=1; char s;
while((s=getchar())<'0'||s>'9') if(s=='-') f=-1;
while(s>='0'&&s<='9') x=(x<<3)+(x<<1)+(s^'0'),s=getchar();
return x*f;
}
const int N=30005;
int n,k,p[N],w[N][15];
int f[N][2];
signed main(){
// freopen("data.in","r",stdin);
// freopen("ans.out","w",stdout);
n=read(),k=read();
int sum=0;
for(int i=1;i<=n;++i){
p[i]=read();
sum+=p[i];
for(int j=1;j<=p[i];++j){
w[i][j]=read();
}
}
// cout<<sum<<endl;
//memset(f,-0x3f,sizeof(f));
f[0][0]=0;
for(int i=1;i<=n;++i){
for(int j=0;j<=k;j++){
if(j+p[i]<=k){
f[j + p[i]][0]=max(f[j + p[i]][0],f[j][0]+w[i][p[i]]);
f[j + p[i]][1]=max(f[j + p[i]][1],f[j][0]+w[i][p[i]]);
}
for(int o=p[i]-1;o>=1;--o){
if(j + o<=k) f[j + o][1]=max(f[j+o][1],f[j+o][0]+w[i][o]);
}
}
// for(int j=1;j<=k;++j){
// cout<<j<<' '<<f[j][0]<<' '<<f[j][1]<<endl;
// }
}
if(sum>=k)cout<<max(f[k][0],f[k][1]);
else cout<<f[sum][0];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 45ms
memory: 3924kb
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:
299167000
result:
wrong answer 1st numbers differ - expected: '68279788', found: '299167000'