# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72020 | (#118) | 박스런 (FXCUP3_box) | C++17 | 189 ms | 7640 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 <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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |