# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73784 | 2018-08-29T03:42:02 Z | 강태규(#2274) | 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) | C++11 | 22 ms | 16644 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <unordered_map> #include <functional> #include <cstring> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; typedef long long llong; typedef long double ld; typedef pair<int, int> pii; typedef pair<llong, llong> pll; int n; int c[1001]; int d[1001]; llong dp[1001][1001]; int cost(int i, int cnt) { if (c[i] != cnt) return 0; return d[i]; } llong pro_dp(int s, int e) { if (dp[s][e] != -1) return dp[s][e]; int cnt = e - s + 2; if (s > 1) dp[s][e] = max(dp[s][e], pro_dp(s - 1, e) + cost(s - 1, cnt)); if (e < n) dp[s][e] = max(dp[s][e], pro_dp(s, e + 1) + cost(e + 1, cnt)); return dp[s][e]; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", c + i); for (int i = 1; i <= n; ++i) scanf("%d", d + i); for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) dp[i][j] = -1; dp[1][n] = 0; for (int i = 1; i <= n; ++i) printf("%lld ", pro_dp(i, i) + cost(i, 1)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 4 ms | 516 KB | Output is correct |
6 | Correct | 3 ms | 648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 4 ms | 516 KB | Output is correct |
6 | Correct | 3 ms | 648 KB | Output is correct |
7 | Correct | 5 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 1196 KB | Output is correct |
9 | Correct | 3 ms | 1260 KB | Output is correct |
10 | Correct | 7 ms | 3312 KB | Output is correct |
11 | Correct | 13 ms | 7044 KB | Output is correct |
12 | Correct | 15 ms | 8352 KB | Output is correct |
13 | Correct | 15 ms | 8772 KB | Output is correct |
14 | Correct | 18 ms | 8772 KB | Output is correct |
15 | Correct | 15 ms | 8772 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 4 ms | 516 KB | Output is correct |
6 | Correct | 3 ms | 648 KB | Output is correct |
7 | Correct | 5 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 1196 KB | Output is correct |
9 | Correct | 3 ms | 1260 KB | Output is correct |
10 | Correct | 7 ms | 3312 KB | Output is correct |
11 | Correct | 13 ms | 7044 KB | Output is correct |
12 | Correct | 15 ms | 8352 KB | Output is correct |
13 | Correct | 15 ms | 8772 KB | Output is correct |
14 | Correct | 18 ms | 8772 KB | Output is correct |
15 | Correct | 15 ms | 8772 KB | Output is correct |
16 | Runtime error | 22 ms | 16644 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Halted | 0 ms | 0 KB | - |