Submission #57315225
Source Code Expand
Copy
#include<bits/stdc++.h>using namespace std;long long n,a[1000001],ans,dp[224524][2];int main(){cin>>n;for(int i=1;i<=n;i++){cin>>a[i];if(i<2)dp[i][1]=a[i];else dp[i][0]=max(dp[i-1][1]+a[i]*2,dp[i-1][0]),dp[i][1]=max(dp[i-1][0]+a[i],dp[i-1][1]);}cout<<max(dp[n][0],dp[n][1]);}
#include<bits/stdc++.h> using namespace std; long long n,a[1000001],ans,dp[224524][2]; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; if(i<2)dp[i][1]=a[i]; else dp[i][0]=max(dp[i-1][1]+a[i]*2,dp[i-1][0]),dp[i][1]=max(dp[i-1][0]+a[i],dp[i-1][1]); } cout<<max(dp[n][0],dp[n][1]); }
Submission Info
Submission Time | |
---|---|
Task | D - Bonus EXP |
User | zhanghe |
Language | C++ 20 (gcc 12.2) |
Score | 400 |
Code Size | 307 Byte |
Status | AC |
Exec Time | 54 ms |
Memory | 8348 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_00.txt, example_01.txt |
All | example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, random_36.txt, random_37.txt, random_38.txt, random_39.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_00.txt | AC | 1 ms | 3500 KB |
example_01.txt | AC | 1 ms | 3504 KB |
hand_00.txt | AC | 38 ms | 8080 KB |
hand_01.txt | AC | 54 ms | 8188 KB |
hand_02.txt | AC | 1 ms | 3660 KB |
hand_03.txt | AC | 38 ms | 8204 KB |
hand_04.txt | AC | 43 ms | 8344 KB |
hand_05.txt | AC | 42 ms | 8152 KB |
hand_06.txt | AC | 1 ms | 3468 KB |
random_00.txt | AC | 25 ms | 8148 KB |
random_01.txt | AC | 32 ms | 8076 KB |
random_02.txt | AC | 25 ms | 8188 KB |
random_03.txt | AC | 25 ms | 8128 KB |
random_04.txt | AC | 43 ms | 8192 KB |
random_05.txt | AC | 48 ms | 8188 KB |
random_06.txt | AC | 26 ms | 8080 KB |
random_07.txt | AC | 31 ms | 8192 KB |
random_08.txt | AC | 22 ms | 8140 KB |
random_09.txt | AC | 48 ms | 8148 KB |
random_10.txt | AC | 32 ms | 8200 KB |
random_11.txt | AC | 18 ms | 8136 KB |
random_12.txt | AC | 29 ms | 8160 KB |
random_13.txt | AC | 25 ms | 8344 KB |
random_14.txt | AC | 39 ms | 8188 KB |
random_15.txt | AC | 35 ms | 8200 KB |
random_16.txt | AC | 48 ms | 8344 KB |
random_17.txt | AC | 42 ms | 8208 KB |
random_18.txt | AC | 22 ms | 8152 KB |
random_19.txt | AC | 26 ms | 8148 KB |
random_20.txt | AC | 32 ms | 8188 KB |
random_21.txt | AC | 44 ms | 8156 KB |
random_22.txt | AC | 33 ms | 8152 KB |
random_23.txt | AC | 30 ms | 8264 KB |
random_24.txt | AC | 34 ms | 8188 KB |
random_25.txt | AC | 36 ms | 8152 KB |
random_26.txt | AC | 35 ms | 8164 KB |
random_27.txt | AC | 36 ms | 8152 KB |
random_28.txt | AC | 36 ms | 8288 KB |
random_29.txt | AC | 35 ms | 8256 KB |
random_30.txt | AC | 50 ms | 8200 KB |
random_31.txt | AC | 50 ms | 8300 KB |
random_32.txt | AC | 50 ms | 8160 KB |
random_33.txt | AC | 50 ms | 8160 KB |
random_34.txt | AC | 50 ms | 8348 KB |
random_35.txt | AC | 50 ms | 8284 KB |
random_36.txt | AC | 50 ms | 8132 KB |
random_37.txt | AC | 50 ms | 8200 KB |
random_38.txt | AC | 50 ms | 8256 KB |
random_39.txt | AC | 51 ms | 8188 KB |