#include <bits/stdc++.h>
using namespace std;
bool canSort(vector<int>& a, int l, int r, int k) {
for (int i = l; i < r; ++i) {
int maxVal = 0;
for (int j = i + 1; j <= r; ++j) {
if (a[i] > a[j] && min(a[i], a[j]) + maxVal > k) {
return false;
}
maxVal = max(maxVal, a[j]);
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(n);
for (auto& i : a) {
cin >> i;
}
while (m--) {
int l, r, k;
cin >> l >> r >> k;
--l, --r;
cout << canSort(a, l, r, k) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
529 ms |
16000 KB |
Output is correct |
2 |
Correct |
492 ms |
10428 KB |
Output is correct |
3 |
Correct |
505 ms |
10564 KB |
Output is correct |
4 |
Correct |
466 ms |
10476 KB |
Output is correct |
5 |
Execution timed out |
3082 ms |
6212 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3044 ms |
1220 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |