QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#300438#4931. Comic BingeLeeShoW#WA 5ms82544kbC++20912b2024-01-08 11:35:512024-01-08 11:35:52

Judging History

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

  • [2024-01-08 11:35:52]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:82544kb
  • [2024-01-08 11:35:51]
  • 提交

answer

#include<algorithm>
#include<iostream>
#include<utility>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#define int long long
#define PB push_back
#define X first
#define Y second
using namespace std;
const int N=1e3+5,MOD=1e9+7;
int A[N]={},B[N]={};
int dp[N][N][10]={};
int vis[N]={};
int n,sum,ans=0x3f3f3f3f;
signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    memset(dp,0x3f,sizeof(dp));
    dp[0][0][0]=0;
    for(int i=1;i<=n;i++) cin>>A[i];
    for(int i=1;i<=n;i++) cin>>B[i];
    for(int i=1;i<=n;i++){
        sum+=B[i];
        for(int j=0;j<=sum;j++){
            if(j>=B[i]) dp[i][j][1]=max(min(dp[i-1][j-B[i]][0],dp[i-1][j-B[i]][1]),j)+A[i];
            dp[i][j][0]=dp[i-1][j][1]+A[i];
        }
    }
    for(int i=0;i<=sum;i++){
        ans=min(ans,dp[n][i][1]);
    }
    cout<<ans<<"\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
3 1 1 1 1 2
1 5 3 3 7 4

output:

13

result:

ok single line: '13'

Test #2:

score: 0
Accepted
time: 0ms
memory: 82476kb

input:

2
2 1
1 1

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 82468kb

input:

1
1
1

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 5ms
memory: 82540kb

input:

161
146 662 336 441 626 77 362 697 911 248 879 40 435 60 518 62 475 908 185 740 435 899 188 673 716 529 524 305 321 998 4 363 598 471 650 379 6 980 971 175 664 328 294 681 201 64 926 608 310 478 404 284 634 239 891 515 433 368 929 457 593 338 432 971 593 134 355 97 658 344 653 592 822 660 403 398 38...

output:

80587

result:

ok single line: '80587'

Test #5:

score: -100
Wrong Answer
time: 3ms
memory: 82504kb

input:

747
4 609 179 580 613 171 82 687 882 977 720 609 967 329 508 803 301 837 550 416 931 416 521 937 268 723 878 33 372 426 2 94 248 979 319 576 859 644 459 365 445 668 337 572 881 775 946 901 992 405 377 896 967 66 792 686 676 232 245 539 217 774 167 747 923 722 295 483 454 195 494 206 779 536 845 438 ...

output:

369692

result:

wrong answer 1st lines differ - expected: '375240', found: '369692'