Submission #475129

#TimeUsernameProblemLanguageResultExecution timeMemory
475129HossamHero7Po (COCI21_po)C++14
40 / 70
1092 ms2252 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' void solve(){ int n; cin>>n; vector <ll> v(n); for(auto &i:v) cin>>i; vector <ll> tar; for(int i=0;i<n;i++) tar.push_back(0); int ans = 0; while(v != tar){ int f = -1; int e = -1; for(int i=0;i<n;i++){ if(v[i] == 0 && e != -1) break; else if(v[i]){ if(f == -1) f = i; e = i; } } ll mn = 1e18; for(int i=f;i<=e;i++){ mn = min(mn,v[i]); } for(int i=f;i<=e;i++){ v[i] -= mn; } ans ++; } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...