#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
int a[N],l[N],r[N],k[N],n,m;
namespace sub1 {
int b[N];
void solve() {
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) b[j] = a[j];
bool check = true;
for (int j = l[i]; j < r[i]; j++)
if (b[j] > b[j + 1]) {
check = false;
break;
}
while (!check) {
bool found = false;
for (int j = l[i]; j < r[i]; j++)
if (b[j] > b[j + 1]) {
if (b[j] + b[j + 1] <= k[i]) swap(b[j],b[j + 1]);
else found = true;
break;
}
if (found) break;
check = true;
for (int j = l[i]; j < r[i]; j++)
if (b[j] > b[j + 1]) {
check = false;
break;
}
}
cout << check << "\n";
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) cin >> l[i] >> r[i] >> k[i];
if (n <= 500 && m <= 500) sub1::solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8656 KB |
Output is correct |
5 |
Correct |
3 ms |
8792 KB |
Output is correct |
6 |
Correct |
10 ms |
8536 KB |
Output is correct |
7 |
Correct |
17 ms |
8540 KB |
Output is correct |
8 |
Correct |
186 ms |
8664 KB |
Output is correct |
9 |
Correct |
196 ms |
8652 KB |
Output is correct |
10 |
Correct |
152 ms |
8784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8656 KB |
Output is correct |
5 |
Correct |
3 ms |
8792 KB |
Output is correct |
6 |
Correct |
10 ms |
8536 KB |
Output is correct |
7 |
Correct |
17 ms |
8540 KB |
Output is correct |
8 |
Correct |
186 ms |
8664 KB |
Output is correct |
9 |
Correct |
196 ms |
8652 KB |
Output is correct |
10 |
Correct |
152 ms |
8784 KB |
Output is correct |
11 |
Incorrect |
2 ms |
8672 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
254 ms |
33220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
10588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8656 KB |
Output is correct |
5 |
Correct |
3 ms |
8792 KB |
Output is correct |
6 |
Correct |
10 ms |
8536 KB |
Output is correct |
7 |
Correct |
17 ms |
8540 KB |
Output is correct |
8 |
Correct |
186 ms |
8664 KB |
Output is correct |
9 |
Correct |
196 ms |
8652 KB |
Output is correct |
10 |
Correct |
152 ms |
8784 KB |
Output is correct |
11 |
Incorrect |
2 ms |
8672 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
8536 KB |
Output is correct |
2 |
Correct |
1 ms |
8540 KB |
Output is correct |
3 |
Correct |
2 ms |
8540 KB |
Output is correct |
4 |
Correct |
1 ms |
8656 KB |
Output is correct |
5 |
Correct |
3 ms |
8792 KB |
Output is correct |
6 |
Correct |
10 ms |
8536 KB |
Output is correct |
7 |
Correct |
17 ms |
8540 KB |
Output is correct |
8 |
Correct |
186 ms |
8664 KB |
Output is correct |
9 |
Correct |
196 ms |
8652 KB |
Output is correct |
10 |
Correct |
152 ms |
8784 KB |
Output is correct |
11 |
Incorrect |
2 ms |
8672 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |