# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1112015 | 0pt1mus23 | Skyline (IZhO11_skyline) | C++14 | 94 ms | 97064 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>
using namespace std;
#define int unsigned long long int
#define ins insert
#define pb push_back
#define endl '\n'
#define putr(x) cout<<x<<endl;return;
#define all(x) x.begin(),x.end()
int nxt(){ int x;cin>>x; return x; }
const int mod = 1e9 +7, sze = 3e2 +23, inf = LLONG_MAX, LG = 20;
// mt19937 rng(time(0));
int dp[301][202][203];
//saksuk, I checked someone's code
void fast(){
int n;
cin>>n;
vector<int> arr(n+1,0);
for(int i=0;i<n;i++){
cin>>arr[i+1];
}
for(int i=0;i<301;i++){
for(int j=0;j<201;j++){
for(int k =0; k<201;k++){
dp[i][j][k]=inf;
}
}
}
for(int i =0;i<=arr[1];i++){
dp[1][0][i]=3*i;
}
for(int i =2;i<=n;i++){
for(int j=0;j<=arr[i-1];j++){
for(int k =0;k<=arr[i];k++){
if(k>0){
dp[i][j][k]=dp[i][j][k-1]+3;
}
if(k>0 && j>0){
dp[i][j][k]=min(dp[i][j][k],dp[i][j-1][k-1] + 5);
}
int sil = min(j,k);
if(sil<=arr[i-2]){
dp[i][j][k]=min(dp[i][j][k],dp[i-1][ arr[i-2] -sil][ j - sil] + sil*7 + 3*(k-sil));
}
}
}
}
putr(dp[ n][arr[n-1] ][arr[n]]);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt = 1;
// cin>>tt;
while(tt--){
fast();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |