이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ii pair<int, int>
using namespace std;
int t[1000001 << 2];
int a[1000001];
void build(int v, int l, int r){
if(l == r){
t[v] = a[l];
return;
}
int mid = (l + r) >> 1;
build(v * 2, l, mid); build(v * 2 + 1, mid + 1, r);
t[v] = max(t[v * 2], t[v * 2 + 1]);
}
int query(int v, int tl, int tr, int l, int r){
if(l > r) return -1;
if(tl == l && tr == r) return t[v];
int tm = (tl + tr) >> 1;
return max(query(v * 2, tl, tm, l, min(r, tm)), query(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int main(){
int N, M;
scanf("%d %d", &N, &M);
for(int i = 1; i <= N; i++){
scanf("%d", &a[i]);
}
build(1, 1, N);
while(M--){
int a, b, k;
scanf("%d %d %d", &a, &b, &k);
int l = a, r = b;
while(l < r){
int mid = (l + r) >> 1;
int ll = query(1, 1, N, l, mid), rr = query(1, 1, N, mid + 1, r);
if(ll <= rr) l = mid + 1;
else r = mid;
}
int ll = query(1, 1, N, a, l), rr = query(1, 1, N, l + 1, b);
if(ll + rr > k) printf("0\n");
else printf("1\n");
}
}
컴파일 시 표준 에러 (stderr) 메시지
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%d %d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~~
sortbooks.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | scanf("%d %d %d", &a, &b, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |