# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475182 | Ahmed57 | Po (COCI21_po) | C++14 | 1090 ms | 1868 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;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long n,ans = 0;
cin>>n;
vector<long long>arr(n);
for(int i=0;i<n;i++)cin>>arr[i];
vector<long long>att(n,0);
while(arr!=att){
long long s=-1,e=-1;
long long m=1e9;
for(int i=0;i<n;i++){
if(arr[i]!=0){
m=min(arr[i],m);
if(s==-1){
s=i;
}
e=i;
}else if(s!=-1)break;
}
if(s!=-1&&e!=-1){
for(int i=s;i<=e;i++){
arr[i]-=m;
}
ans++;
}
}
cout<<ans<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |