# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72229 | 2018-08-26T06:11:15 Z | 마릴린 희정(#2180, gs14004, ho94949) | Gorgeous Pill (FXCUP3_gorgeous) | C++14 | 16 ms | 9560 KB |
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; const int MAXN = 1050; lint dp[MAXN][MAXN]; int n, a[MAXN], b[MAXN]; lint f(int s, int e){ if(~dp[s][e]) return dp[s][e]; lint ret = 0; if(s > 1){ ret = max(ret, f(s - 1, e) + (a[s - 1] == (e - s + 2) ? b[s - 1] : 0)); } if(e < n){ ret = max(ret, f(s, e + 1) + (a[e + 1] == (e - s + 2) ? b[e + 1] : 0)); } return dp[s][e] = ret; } int main(){ scanf("%d",&n); if(n > 1000 ) return 0; for(int i=1; i<=n; i++) scanf("%d",&a[i]); for(int i=1; i<=n; i++) scanf("%d",&b[i]); memset(dp, -1, sizeof(dp)); for(int i=1; i<=n; i++){ lint ans = f(i, i); if(a[i] == 1) ans += b[i]; printf("%lld ", ans); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8952 KB | Output is correct |
2 | Correct | 10 ms | 8952 KB | Output is correct |
3 | Correct | 8 ms | 9096 KB | Output is correct |
4 | Correct | 9 ms | 9096 KB | Output is correct |
5 | Correct | 9 ms | 9236 KB | Output is correct |
6 | Correct | 10 ms | 9332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8952 KB | Output is correct |
2 | Correct | 10 ms | 8952 KB | Output is correct |
3 | Correct | 8 ms | 9096 KB | Output is correct |
4 | Correct | 9 ms | 9096 KB | Output is correct |
5 | Correct | 9 ms | 9236 KB | Output is correct |
6 | Correct | 10 ms | 9332 KB | Output is correct |
7 | Correct | 9 ms | 9332 KB | Output is correct |
8 | Correct | 9 ms | 9332 KB | Output is correct |
9 | Correct | 10 ms | 9332 KB | Output is correct |
10 | Correct | 10 ms | 9332 KB | Output is correct |
11 | Correct | 12 ms | 9340 KB | Output is correct |
12 | Correct | 16 ms | 9368 KB | Output is correct |
13 | Correct | 15 ms | 9388 KB | Output is correct |
14 | Correct | 15 ms | 9524 KB | Output is correct |
15 | Correct | 14 ms | 9560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8952 KB | Output is correct |
2 | Correct | 10 ms | 8952 KB | Output is correct |
3 | Correct | 8 ms | 9096 KB | Output is correct |
4 | Correct | 9 ms | 9096 KB | Output is correct |
5 | Correct | 9 ms | 9236 KB | Output is correct |
6 | Correct | 10 ms | 9332 KB | Output is correct |
7 | Correct | 9 ms | 9332 KB | Output is correct |
8 | Correct | 9 ms | 9332 KB | Output is correct |
9 | Correct | 10 ms | 9332 KB | Output is correct |
10 | Correct | 10 ms | 9332 KB | Output is correct |
11 | Correct | 12 ms | 9340 KB | Output is correct |
12 | Correct | 16 ms | 9368 KB | Output is correct |
13 | Correct | 15 ms | 9388 KB | Output is correct |
14 | Correct | 15 ms | 9524 KB | Output is correct |
15 | Correct | 14 ms | 9560 KB | Output is correct |
16 | Incorrect | 2 ms | 9560 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |