# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
475182 |
2021-09-21T11:05:33 Z |
Ahmed57 |
Po (COCI21_po) |
C++14 |
|
1000 ms |
1868 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
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(s!=-1)break;
}
if(s!=-1&&e!=-1){
for(int i=s;i<=e;i++){
arr[i]-=m;
}
ans++;
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
1077 ms |
1100 KB |
Time limit exceeded |
5 |
Execution timed out |
1049 ms |
1484 KB |
Time limit exceeded |
6 |
Execution timed out |
1090 ms |
1868 KB |
Time limit exceeded |
7 |
Execution timed out |
1073 ms |
1868 KB |
Time limit exceeded |