Submission #475136

# Submission time Handle Problem Language Result Execution time Memory
475136 2021-09-21T09:37:33 Z Mr_OK_Man Po (COCI21_po) C++17
30 / 70
1000 ms 1100 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;
vector<long long >a(n);
 for(int i=0;i<n;i++)
 {
     cin>>a[i];
 }
  while(true)
  {
    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++;
  }
  d:
  cout<<c<<endl;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:51:3: warning: label 'd' defined but not used [-Wunused-label]
   51 |   d:
      |   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Execution timed out 1004 ms 696 KB Time limit exceeded
5 Execution timed out 1081 ms 844 KB Time limit exceeded
6 Execution timed out 1081 ms 1100 KB Time limit exceeded
7 Execution timed out 1084 ms 1100 KB Time limit exceeded