#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
struct MST{
int n;
vector<vector<int>> seg;
void init(int n1){
n = 1;
while(n < n1) n*=2;
}
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,q; cin>>n>>q;
vector<int> v(n); for(int& i : v) cin>>i;
vector<int> pre(n+1);
for(int i = 1; i<n; i++){
pre[i+1] = pre[i] + (v[i] < v[i-1]);
}
while(q--){
int l,r,k; cin>>l>>r>>k;
if(n > 600){
if(pre[r] - pre[l] == 0) cout<<1<<endl;
else cout<<0<<endl;
}
else{
l--; r--;
int mx = 0;
for(int i = l; i <= r; i++){
for(int j = i+1; j<=r; j++){
if(v[i] > v[j]) mx = max(mx,v[i] + v[j]); // ill have to swap them
}
}
if(mx > k) cout<<0<<endl;
else cout<<1<<endl;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
348 KB |
Output is correct |
8 |
Correct |
36 ms |
432 KB |
Output is correct |
9 |
Correct |
10 ms |
348 KB |
Output is correct |
10 |
Correct |
34 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
348 KB |
Output is correct |
8 |
Correct |
36 ms |
432 KB |
Output is correct |
9 |
Correct |
10 ms |
348 KB |
Output is correct |
10 |
Correct |
34 ms |
432 KB |
Output is correct |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
313 ms |
10260 KB |
Output is correct |
2 |
Correct |
326 ms |
10288 KB |
Output is correct |
3 |
Correct |
323 ms |
10128 KB |
Output is correct |
4 |
Correct |
327 ms |
10268 KB |
Output is correct |
5 |
Correct |
324 ms |
10096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
1360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
348 KB |
Output is correct |
8 |
Correct |
36 ms |
432 KB |
Output is correct |
9 |
Correct |
10 ms |
348 KB |
Output is correct |
10 |
Correct |
34 ms |
432 KB |
Output is correct |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
22 ms |
348 KB |
Output is correct |
8 |
Correct |
36 ms |
432 KB |
Output is correct |
9 |
Correct |
10 ms |
348 KB |
Output is correct |
10 |
Correct |
34 ms |
432 KB |
Output is correct |
11 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |