# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40869 | 2018-02-09T15:15:51 Z | XmtosX | Baloni (COCI15_baloni) | C++14 | 1531 ms | 104344 KB |
#include <bits/stdc++.h> using namespace std; int n,h,ans,maxx; set <int> s[1000006]; set <int> ::iterator it; int main() { scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d",&h); s[h].insert(i); maxx=max(maxx,h); } for (int i=0;i<=maxx;i++) s[i].insert(n); for (int i=maxx;i>0;i--) { while (s[i].size()>1) { ans++; int x= (*s[i].begin()); s[i].erase(s[i].begin()); int a=i-1; while ((it=s[a].lower_bound(x))!=(--s[a].end())) { x= (*it); s[a].erase(it); a--; } } } printf("%d",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 47352 KB | Output is correct |
2 | Correct | 45 ms | 47460 KB | Output is correct |
3 | Correct | 45 ms | 47520 KB | Output is correct |
4 | Correct | 44 ms | 47664 KB | Output is correct |
5 | Correct | 1169 ms | 88320 KB | Output is correct |
6 | Correct | 1531 ms | 96464 KB | Output is correct |
7 | Correct | 1154 ms | 96464 KB | Output is correct |
8 | Correct | 1108 ms | 96464 KB | Output is correct |
9 | Correct | 1151 ms | 99640 KB | Output is correct |
10 | Correct | 1305 ms | 104344 KB | Output is correct |