# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96226 | 2019-02-07T09:39:02 Z | Retro3014 | 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) | C++14 | 23 ms | 14460 KB |
#include <iostream> #include <vector> #include <stdio.h> #include <algorithm> using namespace std; #define MAX_N 1000 typedef long long ll; int N; ll dp[MAX_N+1][MAX_N+1]; vector<int> C, D; int main(){ scanf("%d", &N); for(int i=0; i<N; i++){ int a; scanf("%d", &a); C.push_back(a); } for(int i=0; i<N; i++){ int a; scanf("%d", &a); D.push_back(a); } for(int L=N; L>1; L--){ for(int i=0; i+L-1<N; i++){ int j = i+L-1; if(C[i]==L){ dp[i+1][j] = max(dp[i+1][j], dp[i][j]+(ll)D[i]); }else{ dp[i+1][j] = max(dp[i+1][j], dp[i][j]); } if(C[j]==L){ dp[i][j-1] = max(dp[i][j-1], dp[i][j]+(ll)D[j]); }else{ dp[i][j-1] = max(dp[i][j-1], dp[i][j]); } } } for(int i=0; i<N; i++){ if(C[i]==1){ dp[i][i]+=(ll)D[i]; } printf("%lld ", dp[i][i]); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 2296 KB | Output is correct |
11 | Correct | 9 ms | 5496 KB | Output is correct |
12 | Correct | 12 ms | 6776 KB | Output is correct |
13 | Correct | 11 ms | 7288 KB | Output is correct |
14 | Correct | 12 ms | 7288 KB | Output is correct |
15 | Correct | 12 ms | 7288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 5 ms | 2296 KB | Output is correct |
11 | Correct | 9 ms | 5496 KB | Output is correct |
12 | Correct | 12 ms | 6776 KB | Output is correct |
13 | Correct | 11 ms | 7288 KB | Output is correct |
14 | Correct | 12 ms | 7288 KB | Output is correct |
15 | Correct | 12 ms | 7288 KB | Output is correct |
16 | Runtime error | 23 ms | 14460 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Halted | 0 ms | 0 KB | - |