| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1336090 | yhkhoo | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++20 | 163 ms | 145240 KiB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n >> q;
int w[n], mi[18][n], ma[18][n];
memset(mi, INF, sizeof(mi));
memset(ma, 0, sizeof(ma));
for(int i=0; i<n; i++){
cin >> w[i];
mi[0][i] = w[i];
}
for(int k=1; k<18; k++){
for(int i=0; i<n-(1<<(k-1)); i++){
mi[k][i] = min(mi[k-1][i], mi[k-1][i+(1<<(k-1))]);
ma[k][i] = max(ma[k-1][i], ma[k-1][i+(1<<(k-1))]);
}
}
for(int i=0; i<q; i++){
int l, r, m;
cin >> l >> r >> m;
l--; r--;
int ma = -1;
bool ans = 1;
for(int j=l; j<=r; j++){
if(w[j] < ma){
if(w[j] + ma > m){
ans = 0;
break;
}
}
else{
ma = w[j];
int k = bit_floor((unsigned)j);
int mg = min(mi[k][j], mi[k][r - (1<<k) + 1]);
if(mg < w[j] && mg + w[j] > m){
ans = 0;
break;
}
}
}
cout << ans << '\n';
}
return 0;
}
| # | 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... | ||||
