# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72020 | 2018-08-26T04:46:23 Z | (#2175, xdoju, kazel, pps789) | Box Run (FXCUP3_box) | C++17 | 189 ms | 7640 KB |
#include <cstdio> #include <climits> #include <stack> using namespace std; struct S { int x, h; }; int p[500002]; int ans[500002]; stack<S> st; int main(){ int N; scanf("%d", &N); for(int i = 1; i <= N; i++) scanf("%d", &p[i]); for(int i = 1; i <= N; i++) ans[i] = -1; st.push({ 0, INT_MAX }); int last = 0; for(int i = 1; i <= N; i++){ while(!st.empty() && p[i] > st.top().h){ st.pop(); } int width = i - st.top().x - 1; if(width > last){ for(int x = last + 1; x <= width; x++) ans[x] = i - x; last = width; } st.push({ i, p[i] }); } for(int i = 1; i <= N; i++) printf("%d ", ans[i]); printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 2 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Correct | 2 ms | 596 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 596 KB | Output is correct |
11 | Correct | 3 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 596 KB | Output is correct |
5 | Correct | 2 ms | 596 KB | Output is correct |
6 | Correct | 2 ms | 596 KB | Output is correct |
7 | Correct | 2 ms | 596 KB | Output is correct |
8 | Correct | 2 ms | 596 KB | Output is correct |
9 | Correct | 3 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 596 KB | Output is correct |
11 | Correct | 3 ms | 600 KB | Output is correct |
12 | Correct | 2 ms | 632 KB | Output is correct |
13 | Correct | 3 ms | 632 KB | Output is correct |
14 | Correct | 20 ms | 1144 KB | Output is correct |
15 | Correct | 28 ms | 1548 KB | Output is correct |
16 | Correct | 41 ms | 1816 KB | Output is correct |
17 | Correct | 81 ms | 3980 KB | Output is correct |
18 | Correct | 118 ms | 5052 KB | Output is correct |
19 | Correct | 134 ms | 6588 KB | Output is correct |
20 | Correct | 189 ms | 7640 KB | Output is correct |
21 | Correct | 161 ms | 7640 KB | Output is correct |