# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
333808 | limabeans | 스카이라인 (IZhO11_skyline) | C++17 | 358 ms | 232684 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const ll inf = 1e18;
const int maxn = 314;
int n;
int a[maxn];
ll dp[maxn][maxn][maxn];
void setmin(ll &x, ll y) {
x = min(x, y);
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1; i<=n; i++) {
cin>>a[i];
}
for (int i=0; i<=n; i++) {
for (int j=0; j<maxn; j++) {
for (int k=0; k<maxn; k++) {
dp[i][j][k] = inf;
}
}
}
dp[1][0][a[1]] = 0;
for (int i=1; i<=n; i++) {
for (int j=maxn-1; j>=0; j--) {
for (int k=maxn-1; k>=0; k--) {
if (k>0) {
setmin(dp[i][j][k-1], dp[i][j][k]+3);
}
if (j>0 && k>0) {
setmin(dp[i][j-1][k-1], dp[i][j][k]+5);
}
}
}
if (i==n) {
break;
}
// j....k.....a[i+1]
for (int j=0; j<maxn; j++) {
for (int k=0; k<maxn; k++) {
if (a[i+1] >= j && k >= j) {
setmin(dp[i+1][k-j][a[i+1]-j], dp[i][j][k] + 7*j);
}
}
}
}
cout<<dp[n][0][0]<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |