Submission #1112015

# Submission time Handle Problem Language Result Execution time Memory
1112015 2024-11-13T13:57:21 Z 0pt1mus23 Skyline (IZhO11_skyline) C++14
100 / 100
94 ms 97064 KB
#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
1 Correct 52 ms 96964 KB Output is correct
2 Correct 53 ms 96840 KB Output is correct
3 Correct 57 ms 96960 KB Output is correct
4 Correct 55 ms 96840 KB Output is correct
5 Correct 57 ms 96840 KB Output is correct
6 Correct 59 ms 96852 KB Output is correct
7 Correct 59 ms 96840 KB Output is correct
8 Correct 56 ms 96840 KB Output is correct
9 Correct 58 ms 96840 KB Output is correct
10 Correct 60 ms 97008 KB Output is correct
11 Correct 66 ms 96840 KB Output is correct
12 Correct 61 ms 96840 KB Output is correct
13 Correct 68 ms 96840 KB Output is correct
14 Correct 65 ms 97064 KB Output is correct
15 Correct 76 ms 96840 KB Output is correct
16 Correct 77 ms 96832 KB Output is correct
17 Correct 93 ms 96944 KB Output is correct
18 Correct 89 ms 96840 KB Output is correct
19 Correct 87 ms 96832 KB Output is correct
20 Correct 94 ms 96980 KB Output is correct