#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, a, b) for (auto i{a}; i < (b); ++i)
#define per(i, a, b) for (auto i{b}; i-- > (a);)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) static_cast<int>((x).size())
template <class T>
bool uin(T& a, const T& b) {
return a > b ? a = b, true : false;
}
template <class T>
bool uax(T& a, const T& b) {
return a < b ? a = b, true : false;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<int> a(n);
for (auto& x : a) cin >> x;
while (m--) {
int l, r, k;
cin >> l >> r >> k;
--l;
vector<pair<int, int>> v;
rep(i, l, r) v.emplace_back(a[i], i);
sort(all(v));
bool poss = true;
rep(i, 0, r - l) {
auto [two, y] = v[i];
int j = i - 1;
while (j >= 0 && v[j].second < y) --j;
if (j >= 0) poss &= v[j].first + two <= k;
}
cout << poss << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
5 ms |
212 KB |
Output is correct |
8 |
Correct |
13 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
13 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
5 ms |
212 KB |
Output is correct |
8 |
Correct |
13 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
13 ms |
336 KB |
Output is correct |
11 |
Correct |
92 ms |
344 KB |
Output is correct |
12 |
Correct |
298 ms |
428 KB |
Output is correct |
13 |
Correct |
351 ms |
548 KB |
Output is correct |
14 |
Correct |
579 ms |
700 KB |
Output is correct |
15 |
Correct |
617 ms |
708 KB |
Output is correct |
16 |
Execution timed out |
3036 ms |
536 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3069 ms |
18524 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3080 ms |
2668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
5 ms |
212 KB |
Output is correct |
8 |
Correct |
13 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
13 ms |
336 KB |
Output is correct |
11 |
Correct |
92 ms |
344 KB |
Output is correct |
12 |
Correct |
298 ms |
428 KB |
Output is correct |
13 |
Correct |
351 ms |
548 KB |
Output is correct |
14 |
Correct |
579 ms |
700 KB |
Output is correct |
15 |
Correct |
617 ms |
708 KB |
Output is correct |
16 |
Execution timed out |
3036 ms |
536 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
6 ms |
212 KB |
Output is correct |
7 |
Correct |
5 ms |
212 KB |
Output is correct |
8 |
Correct |
13 ms |
336 KB |
Output is correct |
9 |
Correct |
5 ms |
332 KB |
Output is correct |
10 |
Correct |
13 ms |
336 KB |
Output is correct |
11 |
Correct |
92 ms |
344 KB |
Output is correct |
12 |
Correct |
298 ms |
428 KB |
Output is correct |
13 |
Correct |
351 ms |
548 KB |
Output is correct |
14 |
Correct |
579 ms |
700 KB |
Output is correct |
15 |
Correct |
617 ms |
708 KB |
Output is correct |
16 |
Execution timed out |
3036 ms |
536 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |