# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
711736 | Darren0724 | 스카이라인 (IZhO11_skyline) | C++17 | 1 ms | 980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
const int INF=2e9;
const int N=300;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
vector<vector<int>> dp(N+1,vector<int>(N+1,INF)),dp1(N+1,vector<int>(N+1,INF));
dp[0][0]=0;
for(int i=0;i<n;i++){
for(int j=0;j<=v[i];j++){
for(int k=j;k<=N;k++){
dp1[k-j][v[i]-j]=min(dp1[k-j][v[i]-j],dp[j][k]+7*j);
}
}
for(int j=N-1;j>=0;j--){
for(int k=N-1;k>=0;k--){
dp1[j][k]=min(dp1[j][k],dp1[j+1][k+1]+5);
}
}
for(int j=N-1;j>=0;j--){
for(int k=N;k>=0;k--){
dp1[j][k]=min(dp1[j][k],dp1[j+1][k]+3);
}
}
dp=dp1;
dp1.assign(N+1,vector<int>(N+1,INF));
}
int ans=INF;
for(int i=0;i<=N;i++){
ans=min(ans,dp[i][i]+i*7);
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |