# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481257 | FatihSolak | Skyline (IZhO11_skyline) | C++17 | 229 ms | 1180 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 305
using namespace std;
int h[N];
void solve(){
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> h[i];
}
vector<vector<int>> dp(N,vector<int>(N,1e9));
dp[0][0] = 0;
for(int x=1;x<=n;x++){
vector<vector<int>> ndp(N,vector<int>(N,1e9));
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
ndp[max(0,j- i)][max(0,h[x] - i)] = min(ndp[max(0,j- i)][max(0,h[x] - i)],dp[i][j] + 7*i);
}
}
for(int i=N-1;i>=0;i--){
for(int j=N-1;j>=0;j--){
ndp[i][max(0,j-1)] = min(ndp[i][max(0,j-1)],ndp[i][j] + 3);
ndp[max(0,i-1)][max(0,j-1)] = min(ndp[max(0,i-1)][max(0,j-1)],ndp[i][j] + 5);
}
}
dp = ndp;
}
cout << dp[0][0];
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |