# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
475137 | Mr_OK_Man | Po (COCI21_po) | C++17 | 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()
{
// cout << "Hello world!" << endl;
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n,c=0;
cin>>n;
long long a[n],b[n]={};
for(int i=0;i<n;i++)
{
cin>>a[i];
}
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |