# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72009 | BOJ 8481 (#118) | 박스런 (FXCUP3_box) | C++17 | 1080 ms | 1868 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int h[500010];
int x[2100000];
int base;
int get_max(int s, int e){
s += base;
e += base;
int ret = 0;
if(s == e) return x[s];
while(s < e){
if(s % 2 == 1){
ret = max(ret, x[s]);
s += 1;
}
if(e % 2 == 0){
ret = max(ret, x[e]);
e -= 1;
}
s /= 2;
e /= 2;
if(s == e){
ret = max(ret, x[e]);
}
}
return ret;
}
int main(){
scanf("%d", &n);
for(int i=0; i<n; i++){
scanf("%d", &h[i]);
}
base = 1;
while(base < n) base *= 2;
for(int i=0; i<n; i++){
x[base+i] = h[i];
}
for(int i=base-1; i>=1; i--){
x[i] = max(x[2*i], x[2*i+1]);
}
for(int width=1; width<=n; width++){
if(width == n){
printf("-1\n");
continue;
}
vector<int> temp;
for(int i=0; i<=n-width; i++){
temp.push_back(get_max(i, i+width-1));
}
bool stuck = false;
for(int i=1; i<temp.size(); i++){
if(temp[i] > temp[i-1]){
stuck = true;
printf("%d\n", i);
break;
}
}
if(stuck == false){
printf("-1\n");
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |