# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72064 | 2018-08-26T05:06:04 Z | 마릴린 희정(#2180, gs14004, ho94949) | Box Run (FXCUP3_box) | C++17 | 230 ms | 13552 KB |
#include<bits/stdc++.h> using namespace std; int N; int H[1010101]; int ans[1010101]; struct doublepq { priority_queue<int> PQ1, PQ2; void insert(int x) { PQ1.push(x); } void proc() { while(!PQ1.empty() && !PQ2.empty() && PQ1.top() == PQ2.top()) { PQ1.pop(); PQ2.pop(); } } int top() { proc(); return PQ1.top(); } void erase(int v) { PQ2.push(v); } } PQ; int main() { scanf("%d", &N); for(int i=0; i<N; ++i) scanf("%d", H+i); H[N] = (int)1e9+1; int from = 0, to = 0; //multiset<int> S; S.insert(H[0]); PQ.insert(H[0]); for(int t=0; t<N; ++t) { while(PQ.top() >= H[to+1]) { PQ.insert(H[++to]); PQ.erase(H[from++]); } ans[t] = to+1; if(from == 0) PQ.insert(H[++to]); else PQ.insert(H[--from]); } for(int i=0; i<N; ++i) if(ans[i] == N) printf("-1 "); else printf("%d ", ans[i]-i); puts(""); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 508 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 524 KB | Output is correct |
7 | Correct | 2 ms | 572 KB | Output is correct |
8 | Correct | 2 ms | 696 KB | Output is correct |
9 | Correct | 2 ms | 696 KB | Output is correct |
10 | Correct | 2 ms | 696 KB | Output is correct |
11 | Correct | 3 ms | 696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 3 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 3 ms | 508 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 2 ms | 524 KB | Output is correct |
7 | Correct | 2 ms | 572 KB | Output is correct |
8 | Correct | 2 ms | 696 KB | Output is correct |
9 | Correct | 2 ms | 696 KB | Output is correct |
10 | Correct | 2 ms | 696 KB | Output is correct |
11 | Correct | 3 ms | 696 KB | Output is correct |
12 | Correct | 2 ms | 696 KB | Output is correct |
13 | Correct | 4 ms | 696 KB | Output is correct |
14 | Correct | 22 ms | 1908 KB | Output is correct |
15 | Correct | 33 ms | 2688 KB | Output is correct |
16 | Correct | 37 ms | 3340 KB | Output is correct |
17 | Correct | 101 ms | 7288 KB | Output is correct |
18 | Correct | 130 ms | 9468 KB | Output is correct |
19 | Correct | 230 ms | 11832 KB | Output is correct |
20 | Correct | 223 ms | 13552 KB | Output is correct |
21 | Correct | 204 ms | 13552 KB | Output is correct |