Submission #1325670

#TimeUsernameProblemLanguageResultExecution timeMemory
1325670hssaan_arifSkyline (IZhO11_skyline)C++20
0 / 100
0 ms332 KiB
// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
using namespace std;

#define endl "\n"
#define pb push_back
#define int long long
#define fi first
#define se second

const int N = 3e3 + 5, M = 1e9 + 7, LG = 20;

int n , A[N] , B[N] , C[N];

void solve(){
    cin >> n;

    for (int i=1 ; i<=n ; i++){
        cin >> A[i];
        B[i] = C[i] = 0;
    }

    int ans = 0;

    for (int i=2 ; i<=n ; i++){
        for (int k=1 ; k<=200 ; k++){
            if (A[i] && A[i-1]){
                B[i]++;
                A[i]--;
                A[i-1]--;
            }
        }
    }

    for (int i=3 ; i<=n ; i++){
        for (int k=1 ; k<=200 ; k++){
            if (A[i] && B[i-1]){
                C[i]++;
                A[i]--;
                B[i-1]--;
            }

        }
    }

    for (int i=6 ; i<=n ; i++){
        for (int k=1 ; k<=200 ; k++){
            if (B[i] && B[i-2] && B[i-4]){
                C[i]++;
                C[i-3]++;
                B[i]--;
                B[i-2]--;
                B[i-4]--;
            }
            
        }
    }
    

    for (int i=1 ; i<=n ; i++){
        // cout << A[i] << ' ' << B[i] << ' ' << C[i] << endl;
        ans += A[i] * 3;
        ans += B[i] * 5;
        ans += C[i] * 7;
    }

    cout << ans << endl;
}

signed main(){ 
    // freopen("" , "r" , stdin);
    // freopen("" , "w" , stdout);
    // cout << setprecision(30);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int ts = 1;
    // cin >> ts;
    while(ts--){
        solve();
    }
}

// 20
// 23
// 18
// 16
// 23
// 6
// 21
// 15
// 16
// 20
#Verdict Execution timeMemoryGrader output
Fetching results...