# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
40867 | 2018-02-09T15:05:55 Z | XmtosX | Baloni (COCI15_baloni) | C++14 | 2000 ms | 131072 KB |
#include <bits/stdc++.h> using namespace std; int n,h,ans; set <int> s[1000006]; int main() { scanf("%d",&n); for (int i=0;i<n;i++) { scanf("%d",&h); s[h].insert(i); } for (int i=0;i<=1e6;i++) s[i].insert(n); for (int i=1e6;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 (s[a].lower_bound(x)!=(--s[a].end())) { x= (*s[a].lower_bound(x)); s[a].erase(x); a--; } } } cout <<ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 128 ms | 94200 KB | Output is correct |
2 | Correct | 129 ms | 94348 KB | Output is correct |
3 | Correct | 133 ms | 94644 KB | Output is correct |
4 | Correct | 133 ms | 94672 KB | Output is correct |
5 | Execution timed out | 2054 ms | 131072 KB | Time limit exceeded |
6 | Execution timed out | 2061 ms | 131072 KB | Time limit exceeded |
7 | Correct | 1535 ms | 131072 KB | Output is correct |
8 | Correct | 1413 ms | 131072 KB | Output is correct |
9 | Execution timed out | 2031 ms | 131072 KB | Time limit exceeded |
10 | Execution timed out | 2094 ms | 131072 KB | Time limit exceeded |