QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#300432 | #4931. Comic Binge | LeeShoW# | WA | 1ms | 3644kb | C++20 | 1.0kb | 2024-01-08 11:15:31 | 2024-01-08 11:15:32 |
Judging History
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]={};
int vis[N]={};
int n;
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
memset(dp,0x3f,sizeof(dp));
for(int i=1;i<=n;i++) cin>>A[i];
for(int i=1;i<=n;i++) cin>>B[i];
dp[1]=B[1];
for(int i=2;i<=n;i++) dp[i]=min(dp[i-1],dp[i-2])+B[i];
//for(int i=1;i<=n;i++) cout<<dp[i]<<" \n"[i==n];
vis[n]=dp[n];
int now=n;
while(now>1){
if(now>2&&dp[now-2]+B[now]==dp[now]) now-=2;
else now-=1;
vis[now]=dp[now];
}
//for(int i=1;i<=n;i++) cout<<vis[i]<<" \n"[i==n];
int ans=0;
for(int i=1;i<=n;i++){
if(vis[i]) ans=max(vis[i]+A[i],ans+A[i]);
else ans+=A[i];
}
cout<<ans<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3340kb
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: 3464kb
input:
2 2 1 1 1
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3352kb
input:
1 1 1
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3640kb
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: 0ms
memory: 3644kb
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:
375242
result:
wrong answer 1st lines differ - expected: '375240', found: '375242'