QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628484#5303. No Bug No GameDiverbeeRE 0ms3592kbC++141.4kb2024-10-10 20:31:362024-10-10 20:31:41

Judging History

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

  • [2024-10-10 20:31:41]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3592kb
  • [2024-10-10 20:31:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 0x3f3f3f3f;
const int N = 3000+100;
int dp[2][N][2];
int main(){
    int n,k;cin>>n>>k;
    vector<vector<int> >vc(n+1);
    for(int i = 1; i <= n ;++i){
        int x;cin>>x;
        for(int j = 1; j<=x;++j){
            int tem;cin>>tem;
            vc[i].push_back(tem);
        }
    }// vc[i],体积为i+1,的价值

    int gu=1,gv=0;

    for(int i = 0;i<=k;++i)
        for(int j = 0 ;j<2;++j)
                dp[gu][i][j]=-inf;

    dp[gu][0][0] = 0;

    for(int i = 1; i<= n; ++i){
        gu^=1;gv^=1;
        memcpy(dp[gu],dp[gv],sizeof(dp[gv]));
        for(int j=vc[i].size()-1;j>=vc[i].size()-1;--j){//i+1
            for(int u = 0;u<=k;++u){
                if(u+j+1<=k){
                    dp[gu][u+j+1][0] = max(dp[gu][u+j+1][0],dp[gv][u][0]+vc[i][j]);
                    dp[gu][u+j+1][1] = max(dp[gu][u+j+1][1],dp[gv][u][1]+vc[i][j]);
                }
            }
        }

        for(int j = vc[i].size()-2;j>=0;--j){
            for(int u = 0;u<=k;++u){
                if(u+j+1<=k){
                    dp[gu][u+j+1][1] = max(dp[gu][u+j+1][1],dp[gv][u][0]+vc[i][j]);
                }
            }
        }
    }
    
    int ans = -inf;
    for(int i = 0;i<=k;++i)ans = max(ans,dp[gu][i][0]);

    cout<<max(ans,dp[gu][k][1]);

//    system("pause");


    return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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:


result: