# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96226 | Retro3014 | Gorgeous Pill (FXCUP3_gorgeous) | C++14 | 23 ms | 14460 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |