제출 #475144

#제출 시각아이디문제언어결과실행 시간메모리
475144Ahmed57Po (COCI21_po)C++14
30 / 70
1096 ms1840 KiB
#include <bits/stdc++.h> using namespace std; int main() { 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(e!=-1&&s!=-1)break; } if(s!=-1&&e!=-1){ for(int i=s;i<=e;i++){ arr[i]-=m; } }else{ break; } ans++; } cout<<ans<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...