# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51859 | Adhyyan1252 | Baloni (COCI15_baloni) | C++11 | 1873 ms | 89176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
//1143
#define HMAX 1000004
set<int> a[HMAX];
int main(){
int n; cin>>n;
int h[n];
for(int i = 0; i < n; i++){
int t; cin>>t;
a[t].insert(i);
}
int ans = 0;
for(int cur = HMAX-1; cur >= 1; cur--){
while(a[cur].size() != 0){
ans++;
int indx = *a[cur].begin();
a[cur].erase(a[cur].begin());
int temp = cur-1;
set<int>::iterator it;
while((it = a[temp].lower_bound(indx)) != a[temp].end()){
indx = *it;
a[temp].erase(it);
temp--;
}
}
}
cout<<ans<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |