Submission #782956

# Submission time Handle Problem Language Result Execution time Memory
782956 2023-07-14T12:37:13 Z 1075508020060209tc Candies (JOI18_candies) C++14
8 / 100
652 ms 408692 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
int ar[500005];
int dp[5010][5010];

signed main(){
cin>>n;
for(int i=1;i<=n;i++){
    cin>>ar[i];
}
for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
        dp[i][j]=-1e16;
    }
}
dp[0][0]=0;
dp[1][0]=0;
dp[1][1]=ar[1];
for(int i=2;i<=n;i++){
    for(int j=1;j<=i;j++){
        dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+ar[i]);
    }
}
for(int i=1;i<=(n+1)/2;i++){
    cout<<dp[n][i]<<"\n";
}


}
# Verdict Execution time Memory Grader output
1 Correct 17 ms 39732 KB Output is correct
2 Correct 17 ms 39704 KB Output is correct
3 Correct 17 ms 39692 KB Output is correct
4 Correct 17 ms 39772 KB Output is correct
5 Correct 17 ms 39764 KB Output is correct
6 Correct 18 ms 39704 KB Output is correct
7 Correct 21 ms 39764 KB Output is correct
8 Correct 18 ms 39756 KB Output is correct
9 Correct 18 ms 39720 KB Output is correct
10 Correct 18 ms 39652 KB Output is correct
11 Correct 17 ms 39632 KB Output is correct
12 Correct 18 ms 39644 KB Output is correct
13 Correct 18 ms 39636 KB Output is correct
14 Correct 18 ms 39624 KB Output is correct
15 Correct 18 ms 39724 KB Output is correct
16 Correct 18 ms 39716 KB Output is correct
17 Correct 18 ms 39636 KB Output is correct
18 Correct 18 ms 39732 KB Output is correct
19 Correct 19 ms 39672 KB Output is correct
20 Correct 19 ms 39744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 39732 KB Output is correct
2 Correct 17 ms 39704 KB Output is correct
3 Correct 17 ms 39692 KB Output is correct
4 Correct 17 ms 39772 KB Output is correct
5 Correct 17 ms 39764 KB Output is correct
6 Correct 18 ms 39704 KB Output is correct
7 Correct 21 ms 39764 KB Output is correct
8 Correct 18 ms 39756 KB Output is correct
9 Correct 18 ms 39720 KB Output is correct
10 Correct 18 ms 39652 KB Output is correct
11 Correct 17 ms 39632 KB Output is correct
12 Correct 18 ms 39644 KB Output is correct
13 Correct 18 ms 39636 KB Output is correct
14 Correct 18 ms 39624 KB Output is correct
15 Correct 18 ms 39724 KB Output is correct
16 Correct 18 ms 39716 KB Output is correct
17 Correct 18 ms 39636 KB Output is correct
18 Correct 18 ms 39732 KB Output is correct
19 Correct 19 ms 39672 KB Output is correct
20 Correct 19 ms 39744 KB Output is correct
21 Runtime error 652 ms 408692 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -