//Bismillahir-Rahmanir-Rahim
#include <bits/stdc++.h>
using namespace std;
#define flash ios_base::sync_with_stdio(0),cin.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define dbg(x) cerr << #x << " = " << x << "\n";
#define ff first
#define ss second
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma comment (linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
const long long INF = 1e9 + 7;
const long long MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
const int lg = 20;
int n, m, a[maxn], b[maxn], x[maxn], pref[maxn];
vector <int> v;
void press_F_() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
if (a[i - 1] <= a[i]) {
x[i] = 1;
}
}
for (int i = 1; i <= n; i++) {
pref[i] = pref[i - 1] + x[i];
}
if (n > 500 || m > 500) {
while(m--) {
int l, r, k;
cin >> l >> r >> k;
if (pref[r] - pref[l - 1] == r - l + 1 || pref[r] - pref[l - 1] == r - l) {
cout << 1 << '\n';
} else {
cout << 0 << '\n';
}
}
return;
}
while(m--) {
int l, r, k;
cin >> l >> r >> k;
for (int j = l; j <= r; j++) {
b[j] = a[j];
}
for (int j = l; j <= r; j++) {
for (int i = l; i < r; i++) {
if (b[i] > b[i + 1] && b[i] + b[i + 1] <= k) {
swap(b[i], b[i + 1]);
}
}
}
bool ok = 1;
for (int i = l; i < r; i++) {
if (b[i] > b[i + 1]) {
cout << 0 << '\n';
ok = 0;
break;
}
}
if (ok) {
cout << 1 << '\n';
}
}
}
int main() {
flash;
int T = 1;
// cin >> T;
for (int i = 1; i <= T; i++) {
press_F_();
}
//Respa gold 2023-2024 InshAllah
return 0;
}
/*
Maybe not today and tomorrow, but InshAllah one day I will reach expert
*/
// g++ -std=c++17 main.cpp
// ./a.out
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
38 ms |
6596 KB |
Output is correct |
7 |
Correct |
36 ms |
6492 KB |
Output is correct |
8 |
Correct |
54 ms |
6492 KB |
Output is correct |
9 |
Correct |
17 ms |
6492 KB |
Output is correct |
10 |
Correct |
49 ms |
6492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
38 ms |
6596 KB |
Output is correct |
7 |
Correct |
36 ms |
6492 KB |
Output is correct |
8 |
Correct |
54 ms |
6492 KB |
Output is correct |
9 |
Correct |
17 ms |
6492 KB |
Output is correct |
10 |
Correct |
49 ms |
6492 KB |
Output is correct |
11 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
362 ms |
15832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
28 ms |
9048 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
38 ms |
6596 KB |
Output is correct |
7 |
Correct |
36 ms |
6492 KB |
Output is correct |
8 |
Correct |
54 ms |
6492 KB |
Output is correct |
9 |
Correct |
17 ms |
6492 KB |
Output is correct |
10 |
Correct |
49 ms |
6492 KB |
Output is correct |
11 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
4 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
2 ms |
6488 KB |
Output is correct |
6 |
Correct |
38 ms |
6596 KB |
Output is correct |
7 |
Correct |
36 ms |
6492 KB |
Output is correct |
8 |
Correct |
54 ms |
6492 KB |
Output is correct |
9 |
Correct |
17 ms |
6492 KB |
Output is correct |
10 |
Correct |
49 ms |
6492 KB |
Output is correct |
11 |
Incorrect |
2 ms |
4440 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |