QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#646452 | #5303. No Bug No Game | sw7777 | WA | 0ms | 5656kb | C++17 | 1.3kb | 2024-10-16 23:11:45 | 2024-10-16 23:11:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f
const int N=3e3+10;
int w[N][N],v[N][N],dp[N][2],s[N],n,c;//dp表示体积为x的背包能装的最大价值
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>c;
for(int i=1;i<=c;i++){
for(int j=0;j<2;j++){
dp[i][j]=-1;
}
}
for(int i=1;i<=n;i++){
cin>>s[i];
for(int j=1;j<=s[i];j++){
w[i][j]=j;
cin>>v[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=c;j>=0;j--){
for(int k=0;k<=s[i];k++){//k=0代表不取
if(j>=w[i][k]){
if(k==s[i]){
dp[j][1]=max(dp[j][1],v[i][k]+dp[j-w[i][k]][1]);
dp[j][0]=max(dp[j][0],v[i][k]+dp[j-w[i][k]][0]);
}
else{
for(int p=1;p<w[i][k];p++){
if(dp[c-p][0]!=-1) dp[c][1]=max(dp[c][1],dp[c-p][0]+v[i][k]);
}
}
}
}
}
}
int x=0;
for(int i=1;i<=c;i++){
x=max(dp[i][0],x);
}
cout<<max(x,dp[c][1])<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5656kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
6
result:
wrong answer 1st numbers differ - expected: '9', found: '6'