# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
589648 | 2022-07-05T04:46:53 Z | 반딧불(#8407) | Gorgeous Pill (FXCUP3_gorgeous) | C++14 | 22 ms | 21596 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int c[300002]; ll arr[300002]; ll DP[1002][1002]; int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &c[i]); for(int i=1; i<=n; i++) scanf("%lld", &arr[i]); for(int d=n-1; d>=1; d--){ for(int i=1; i+d<=n; i++){ int j = i+d; DP[i+1][j] = max(DP[i+1][j], DP[i][j] + (c[i] == d+1 ? arr[i] : 0)); DP[i][j-1] = max(DP[i][j-1], DP[i][j] + (c[j] == d+1 ? arr[j] : 0)); } } for(int i=1; i<=n; i++) printf("%lld ", DP[i][i] + (c[i] == 1 ? arr[i] : 0)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 2 ms | 2260 KB | Output is correct |
11 | Correct | 4 ms | 5460 KB | Output is correct |
12 | Correct | 5 ms | 6720 KB | Output is correct |
13 | Correct | 6 ms | 7252 KB | Output is correct |
14 | Correct | 6 ms | 7224 KB | Output is correct |
15 | Correct | 6 ms | 7252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 304 KB | Output is correct |
4 | Correct | 0 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 724 KB | Output is correct |
9 | Correct | 1 ms | 724 KB | Output is correct |
10 | Correct | 2 ms | 2260 KB | Output is correct |
11 | Correct | 4 ms | 5460 KB | Output is correct |
12 | Correct | 5 ms | 6720 KB | Output is correct |
13 | Correct | 6 ms | 7252 KB | Output is correct |
14 | Correct | 6 ms | 7224 KB | Output is correct |
15 | Correct | 6 ms | 7252 KB | Output is correct |
16 | Runtime error | 22 ms | 21596 KB | Execution killed with signal 11 |
17 | Halted | 0 ms | 0 KB | - |