QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668616#5303. No Bug No Gameparamec1um#WA 82ms144928kbC++201.2kb2024-10-23 15:14:392024-10-23 15:14:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-23 15:14:46]
  • 评测
  • 测评结果:WA
  • 用时:82ms
  • 内存:144928kb
  • [2024-10-23 15:14:39]
  • 提交

answer

#include<iostream>

using namespace std;
#define ll long long
int n,k;
ll dp[3005][3005][2];
ll p[3005];
ll w[3005][20];
int main(){
 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    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];
    }

    for(int i=1;i<=n;i++)
    for(int j=k;j>=1;j--){
        dp[i][j][1]=max(dp[i-1][j][0],dp[i-1][j][1]);
        if(j>=p[i])
        {
            dp[i][j][0]=max(dp[i-1][j][0],dp[i-1][j-p[i]][0]+w[i][p[i]]);
            dp[i][j][1]=max(max(dp[i][j][0],dp[i][j][1]),dp[i-1][j-p[i]][1]+w[i][p[i]]);
        }
        
        for(int pp=p[i];pp>=1;pp--){
            if(j>=pp){
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j-pp][0]+w[i][pp]);
            }
        }
    }
    
    // for(int i=1;i<=n;i++)
    // {
    //     cout<<"\n";
    //     for(int j=1;j<=k;j++)
    //     cout<<dp[i][j][0]<<" ";
    // }
    // cout<<"\n";
    //  for(int i=1;i<=n;i++)
    // {
    //     cout<<"\n";
    //     for(int j=1;j<=k;j++)
    //     cout<<dp[i][j][1]<<" ";
    // }
    // cout<<"\n";
    cout<<max(dp[n][k][0],dp[n][k][1]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3632kb

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: 82ms
memory: 144928kb

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:

68254546

result:

wrong answer 1st numbers differ - expected: '68279788', found: '68254546'