# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
960218 | Isam | 스카이라인 (IZhO11_skyline) | C++17 | 110 ms | 55376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
constexpr int inf = 1E9;
int n, h[305], dp[305][205][205];
int f(int i, int x, int y){
if(i == n + 1) return 0;
if(dp[i][x][y]) return dp[i][x][y];
int res = inf;
if(!x) res = f(i + 1, y, h[i+2]);
else{
res = min(res, f(i, x - 1, y) + 3);
if(y){
res = min(res, f(i, x - 1, y - 1) + 5);
if(x <= min(y, h[i + 2])) res = min(res, f(i + 1, y - x, h[i + 2] - x) + 7 * x);
}
}
return dp[i][x][y] = res;
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
register int j(1);
loop:
cin >> h[j++];
if(j <= n) goto loop;
cout << f(1, h[1], h[2]) << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |