# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
73823 | 2018-08-29T05:34:18 Z | 김세빈(#2276) | 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) | C++11 | 1500 ms | 1060 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[1010][1010]; ll C[1010], D[1010]; ll n; ll f(ll l, ll r) { if(dp[l][r]) return dp[l][r]; ll &ret = dp[l][r]; if(l > 1) ret = max(ret, f(l - 1, r) + (C[l - 1] == r - l + 2) * D[l - 1]); if(r < n) ret = max(ret, f(l, r + 1) + (C[r + 1] == r - l + 2) * D[r + 1]); return ret; } int main() { ll i; 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++){ printf("%lld ", f(i, i) + (C[i] == 1) * D[i]); } printf("\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 3 ms | 528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 3 ms | 528 KB | Output is correct |
7 | Correct | 3 ms | 652 KB | Output is correct |
8 | Correct | 3 ms | 908 KB | Output is correct |
9 | Correct | 27 ms | 1060 KB | Output is correct |
10 | Execution timed out | 1570 ms | 1060 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 3 ms | 488 KB | Output is correct |
4 | Correct | 3 ms | 488 KB | Output is correct |
5 | Correct | 2 ms | 500 KB | Output is correct |
6 | Correct | 3 ms | 528 KB | Output is correct |
7 | Correct | 3 ms | 652 KB | Output is correct |
8 | Correct | 3 ms | 908 KB | Output is correct |
9 | Correct | 27 ms | 1060 KB | Output is correct |
10 | Execution timed out | 1570 ms | 1060 KB | Time limit exceeded |
11 | Halted | 0 ms | 0 KB | - |