Submission #475136

#TimeUsernameProblemLanguageResultExecution timeMemory
475136Mr_OK_ManPo (COCI21_po)C++17
30 / 70
1084 ms1100 KiB
#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 (stderr)

Main.cpp: In function 'int main()':
Main.cpp:51:3: warning: label 'd' defined but not used [-Wunused-label]
   51 |   d:
      |   ^
#Verdict Execution timeMemoryGrader output
Fetching results...