#include <bits/stdc++.h>
using namespace std;
vector<int> a(1000005);
bool check(int l, int r, int w)
{
vector<int> b(a.begin() + l - 1, a.begin() + r);
int n = b.size();
bool res = true;
while (res)
{
res = false;
for (int i = 0; i < n - 1; ++i)
{
if (b[i] > b[i + 1] && b[i] + b[i + 1] <= w)
{
swap(b[i], b[i + 1]);
res = true;
}
}
}
for (int i = 1; i < n; ++i)
{
if (b[i] < b[i - 1])
{
return false;
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
for (int i = 0; i < m; ++i)
{
int l, r, w;
cin >> l >> r >> w;
if (check(l, r, w))
{
cout << 1 << '\n';
}
else
{
cout << 0 << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
3 ms |
4188 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
2 ms |
4188 KB |
Output is correct |
6 |
Correct |
15 ms |
4188 KB |
Output is correct |
7 |
Correct |
14 ms |
4188 KB |
Output is correct |
8 |
Correct |
10 ms |
4392 KB |
Output is correct |
9 |
Correct |
10 ms |
4188 KB |
Output is correct |
10 |
Correct |
7 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
3 ms |
4188 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
2 ms |
4188 KB |
Output is correct |
6 |
Correct |
15 ms |
4188 KB |
Output is correct |
7 |
Correct |
14 ms |
4188 KB |
Output is correct |
8 |
Correct |
10 ms |
4392 KB |
Output is correct |
9 |
Correct |
10 ms |
4188 KB |
Output is correct |
10 |
Correct |
7 ms |
4188 KB |
Output is correct |
11 |
Correct |
655 ms |
4436 KB |
Output is correct |
12 |
Execution timed out |
3021 ms |
4444 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3086 ms |
20292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3048 ms |
5212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
3 ms |
4188 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
2 ms |
4188 KB |
Output is correct |
6 |
Correct |
15 ms |
4188 KB |
Output is correct |
7 |
Correct |
14 ms |
4188 KB |
Output is correct |
8 |
Correct |
10 ms |
4392 KB |
Output is correct |
9 |
Correct |
10 ms |
4188 KB |
Output is correct |
10 |
Correct |
7 ms |
4188 KB |
Output is correct |
11 |
Correct |
655 ms |
4436 KB |
Output is correct |
12 |
Execution timed out |
3021 ms |
4444 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4188 KB |
Output is correct |
2 |
Correct |
1 ms |
4188 KB |
Output is correct |
3 |
Correct |
3 ms |
4188 KB |
Output is correct |
4 |
Correct |
2 ms |
4188 KB |
Output is correct |
5 |
Correct |
2 ms |
4188 KB |
Output is correct |
6 |
Correct |
15 ms |
4188 KB |
Output is correct |
7 |
Correct |
14 ms |
4188 KB |
Output is correct |
8 |
Correct |
10 ms |
4392 KB |
Output is correct |
9 |
Correct |
10 ms |
4188 KB |
Output is correct |
10 |
Correct |
7 ms |
4188 KB |
Output is correct |
11 |
Correct |
655 ms |
4436 KB |
Output is correct |
12 |
Execution timed out |
3021 ms |
4444 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |