QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#133678#4931. Comic Bingewtn135687#WA 1ms3648kbC++14859b2023-08-02 12:51:202023-08-02 12:51:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 12:51:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2023-08-02 12:51:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

const int N = 1e3+10,mo = 1e9+7;

int a[N],b[N];
int pre[N],suf[N];
int dp1[N],dp2[N];
inline void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i) {
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
    }
    for(int i=1;i<=n;++i) cin>>b[i];
    for(int i=n;i>=1;--i) suf[i]=suf[i+1]+a[i];
    dp1[n+1]=1e18,dp2[0]=1e18,dp1[n]=a[n]+b[n],dp2[1]=a[1]+b[1];
    for(int i=n-1;i>=1;--i){
        dp1[i]=max(min(dp1[i+1],dp1[i+2]),suf[i])+b[i];
    }
    for(int i=2;i<=n;++i){
        dp2[i]=max(min(dp2[i+1],dp2[i+2]),pre[i])+b[i];
    }
    cout<<min(dp1[1],dp2[n])<<endl;
}



signed main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int WTN666=1;//cin>>WTN666;
    while(WTN666--){
        solve();
    }
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3648kb

input:

2
2 1
1 1

output:

4

result:

ok single line: '4'

Test #3:

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

input:

1
1
1

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3484kb

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: 0
Accepted
time: 1ms
memory: 3460kb

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:

375240

result:

ok single line: '375240'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3504kb

input:

354
676 379 988 658 926 360 253 901 720 984 387 31 760 194 126 113 974 43 150 228 700 447 346 837 187 222 391 494 972 930 115 668 34 799 797 551 820 981 486 589 961 46 628 198 591 405 833 602 2 772 197 414 288 711 447 790 124 318 860 980 716 650 771 881 92 556 502 742 120 771 275 909 921 151 773 559...

output:

184276

result:

wrong answer 1st lines differ - expected: '184280', found: '184276'