# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
338171 | juggernaut | Skyline (IZhO11_skyline) | C++14 | 194 ms | 49604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
const int N=303;
const int M=202;
int dp[N][M][M],arr[N],n;
int rec(int pos,int a1,int a2){
if(pos>=n)
return min(a1,a2)*5+(max(a1,a2)-min(a1,a2))*3;
int &ret=dp[pos][a1][a2];
if(~ret)
return ret;
ret=INF;
int val=min(arr[pos],min(a1,a2));
if(val==a2)
ret=min(ret,rec(pos+1,arr[pos]-val,a1-val)+val*7);
if(a1 and a2)
ret=min(ret,rec(pos,a1-1,a2-1)+5);
if(a2)
ret=min(ret,rec(pos,a1,a2-1)+3);
return ret;
//a2 a1 a[pos]
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",arr+i);
memset(dp,-1,sizeof dp);
printf("%d\n",rec(2,arr[1],arr[0]));
return 0;
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |