Submission #475137

# Submission time Handle Problem Language Result Execution time Memory
475137 2021-09-21T09:40:11 Z Mr_OK_Man Po (COCI21_po) C++17
30 / 70
1000 ms 1868 KB
#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
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Execution timed out 1086 ms 972 KB Time limit exceeded
5 Execution timed out 1073 ms 1356 KB Time limit exceeded
6 Execution timed out 1090 ms 1868 KB Time limit exceeded
7 Execution timed out 1084 ms 1868 KB Time limit exceeded