| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 764512 | Trunkty | 스카이라인 (IZhO11_skyline) | C++14 | 62 ms | 980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,tot;
int arr[305];
int dp[205][205],dp2[205][205];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++){
cin >> arr[i];
tot += 3LL*arr[i];
}
for(int j=0;j<=200;j++){
for(int k=0;k<=200;k++){
dp[j][k] = -2e9;
dp2[j][k] = -2e9;
}
}
dp[0][0] = 0;
for(int i=1;i<=n;i++){
for(int j=0;j<=200;j++){
for(int k=0;k<=200;k++){
int x = min(arr[i],min(j,k));
dp2[k-x][arr[i]-x] = max(dp2[k-x][arr[i]-x],dp[j][k]+x*2LL);
}
}
for(int j=200;j>=1;j--){
for(int k=200;k>=1;k--){
dp2[j-1][k-1] = max(dp2[j-1][k-1],dp2[j][k]+1LL);
}
}
for(int j=0;j<=200;j++){
for(int k=0;k<=200;k++){
dp[j][k] = dp2[j][k];
dp2[j][k] = -2e9;
}
}
}
int maxi=0;
for(int j=0;j<=200;j++){
for(int k=0;k<=200;k++){
maxi = max(maxi,dp[j][k]);
}
}
cout << tot-maxi << "\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
