# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
96724 | Retro3014 | Candies (JOI18_candies) | C++17 | 186 ms | 69100 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
#define MAX_N 2000
#define INF 1000000000000000000LL
typedef long long ll;
int N;
vector<ll> v;
ll dp[MAX_N+10][MAX_N+10];
int main(){
scanf("%d", &N);
for(int i=0; i<N; i++){
ll x;
scanf("%lld", &x); v.push_back(x);
}
for(int i=0; i<N; i++){
for(int j=1; j<=((N+1)/2); j++){
dp[i][j] = -INF;
}
}
for(int i=0; i<N; i++){
for(int j=1; j<=((i+2)/2); j++){
if(i==0){
dp[i][j] = v[i];
}else if(i==1){
dp[i][j] = max(v[0], v[1]);
}else{
dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+v[i]);
}
}
}
for(int i=1; i<=((N+1)/2); i++){
printf("%lld\n", dp[N-1][i]);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |