# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73828 | 2018-08-29T05:37:15 Z | 김세빈(#2276) | Gorgeous Pill (FXCUP3_gorgeous) | C++11 | 42 ms | 16776 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[1010][1010]; ll C[1010], D[1010]; ll n; int main() { ll i, j; scanf("%lld", &n); for(i=1; i<=n; i++){ scanf("%lld", C + i); } for(i=1; i<=n; i++){ scanf("%lld", D + i); } for(i=1; i<=n; i++){ for(j=n; j>=i; j--){ if(i > 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] + (C[i - 1] == j - i + 2) * D[i - 1]); if(j < n) dp[i][j] = max(dp[i][j], dp[i][j + 1] + (C[j + 1] == j - i + 2) * D[j + 1]); } } for(i=1; i<=n; i++){ printf("%lld ", dp[i][i] + (C[i] == 1) * D[i]); } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 4 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 4 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 688 KB | Output is correct |
8 | Correct | 2 ms | 976 KB | Output is correct |
9 | Correct | 3 ms | 976 KB | Output is correct |
10 | Correct | 6 ms | 2512 KB | Output is correct |
11 | Correct | 11 ms | 5764 KB | Output is correct |
12 | Correct | 14 ms | 7008 KB | Output is correct |
13 | Correct | 16 ms | 7684 KB | Output is correct |
14 | Correct | 15 ms | 7684 KB | Output is correct |
15 | Correct | 13 ms | 7684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 484 KB | Output is correct |
3 | Correct | 2 ms | 484 KB | Output is correct |
4 | Correct | 4 ms | 484 KB | Output is correct |
5 | Correct | 2 ms | 564 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 688 KB | Output is correct |
8 | Correct | 2 ms | 976 KB | Output is correct |
9 | Correct | 3 ms | 976 KB | Output is correct |
10 | Correct | 6 ms | 2512 KB | Output is correct |
11 | Correct | 11 ms | 5764 KB | Output is correct |
12 | Correct | 14 ms | 7008 KB | Output is correct |
13 | Correct | 16 ms | 7684 KB | Output is correct |
14 | Correct | 15 ms | 7684 KB | Output is correct |
15 | Correct | 13 ms | 7684 KB | Output is correct |
16 | Runtime error | 42 ms | 16776 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Halted | 0 ms | 0 KB | - |