# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47853 | 2018-05-08T08:52:47 Z | Just_Solve_The_Problem | Candies (JOI18_candies) | C++11 | 5000 ms | 6456 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = (int)2e5 + 7; ll a[N], dp[2][N]; int n; main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); } for (int j = 1; j <= (n + 1) / 2; j++) { memset(dp[j & 1], 0, sizeof dp[j & 1]); for (int i = j * 2 - 1; i <= n; i++) { dp[j & 1][i] = dp[j & 1][i - 1]; dp[j & 1][i] = max(dp[j & 1][i], dp[j & 1 ^ 1][i - 2] + a[i]); } printf("%lld\n", dp[j & 1][n]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 3448 KB | Output is correct |
2 | Correct | 85 ms | 3560 KB | Output is correct |
3 | Correct | 91 ms | 3632 KB | Output is correct |
4 | Correct | 91 ms | 3632 KB | Output is correct |
5 | Correct | 86 ms | 3632 KB | Output is correct |
6 | Correct | 92 ms | 3688 KB | Output is correct |
7 | Correct | 96 ms | 3768 KB | Output is correct |
8 | Correct | 85 ms | 3768 KB | Output is correct |
9 | Correct | 91 ms | 3808 KB | Output is correct |
10 | Correct | 89 ms | 3808 KB | Output is correct |
11 | Correct | 87 ms | 3808 KB | Output is correct |
12 | Correct | 85 ms | 3808 KB | Output is correct |
13 | Correct | 85 ms | 3844 KB | Output is correct |
14 | Correct | 84 ms | 3844 KB | Output is correct |
15 | Correct | 91 ms | 3844 KB | Output is correct |
16 | Correct | 85 ms | 3844 KB | Output is correct |
17 | Correct | 87 ms | 3844 KB | Output is correct |
18 | Correct | 90 ms | 3884 KB | Output is correct |
19 | Correct | 95 ms | 3884 KB | Output is correct |
20 | Correct | 88 ms | 3884 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 3448 KB | Output is correct |
2 | Correct | 85 ms | 3560 KB | Output is correct |
3 | Correct | 91 ms | 3632 KB | Output is correct |
4 | Correct | 91 ms | 3632 KB | Output is correct |
5 | Correct | 86 ms | 3632 KB | Output is correct |
6 | Correct | 92 ms | 3688 KB | Output is correct |
7 | Correct | 96 ms | 3768 KB | Output is correct |
8 | Correct | 85 ms | 3768 KB | Output is correct |
9 | Correct | 91 ms | 3808 KB | Output is correct |
10 | Correct | 89 ms | 3808 KB | Output is correct |
11 | Correct | 87 ms | 3808 KB | Output is correct |
12 | Correct | 85 ms | 3808 KB | Output is correct |
13 | Correct | 85 ms | 3844 KB | Output is correct |
14 | Correct | 84 ms | 3844 KB | Output is correct |
15 | Correct | 91 ms | 3844 KB | Output is correct |
16 | Correct | 85 ms | 3844 KB | Output is correct |
17 | Correct | 87 ms | 3844 KB | Output is correct |
18 | Correct | 90 ms | 3884 KB | Output is correct |
19 | Correct | 95 ms | 3884 KB | Output is correct |
20 | Correct | 88 ms | 3884 KB | Output is correct |
21 | Execution timed out | 5036 ms | 6456 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |