Submission #475139

#TimeUsernameProblemLanguageResultExecution timeMemory
475139Mr_OK_ManPo (COCI21_po)C++17
30 / 70
1093 ms1868 KiB
#include <bits/stdc++.h> using namespace std; int main() { // cout << "Hello world!" << endl; ios_base::sync_with_stdio(0); cin.tie(0); long long n,c=0; cin>>n; vector<long long >a(n); for(int i=0;i<n;i++) { cin>>a[i]; } vector<long long>b(n,0); while(a!=b) { long long s=-1,e=-1; long long m=1e9+1; for(int i=0;i<n;i++) { if(a[i]!=0) { m=min(a[i],m); if(s==-1) { s=i; } e=i; } else { if(e!=-1&&s!=-1)break; } } //cout<<s<<" "<<e<<endl; if(s!=-1&&e!=-1) { for(int i=s;i<=e;i++) { a[i]-=m; } } else { break; } c++; } cout<<c<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...