# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475129 | HossamHero7 | Po (COCI21_po) | C++14 | 1092 ms | 2252 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |