#pragma GCC optimize("O3", "unroll-loops") // "Ofast"
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt")
#include <bits/stdc++.h>
#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ff first
#define ss second
#define dbg(x) cerr << #x << " = " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vvi = vt< vt<int> >;
const int N = 1e6 + 5, mod = 1e9 + 7, inf = 1e18 + 7, B = 500, LIM = (1ll << 60);
const double eps = 1e-6;
int n, m;
vt<int> w(N), ans(N), p(N);
void solve_1_2 () {
for (int q = 1; q <= m; q++) {
int l, r, k;
cin >> l >> r >> k;
int res = -inf, mx = -inf;
for (int i = l; i <= r; i++) {
if (mx > w[i]) res = max(res, mx + w[i]);
mx = max(mx, w[i]);
}
ans[q] = (res <= k);
}
for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}
void solve_3 () {
for (int i = 2; i <= n; i++) p[i] = p[i - 1] + (w[i] >= w[i - 1]);
for (int q = 1; q <= m; q++) {
int l, r, k;
cin >> l >> r >> k;
ans[q] = (p[r] - p[l - 1] + 1 == r - l + 1);
}
for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
}
void solve () {
cin >> n >> m;
int mn = inf;
for (int i = 1; i <= n; i++) cin >> w[i], mn = min(mn, w[i]);
bool sub_1_2 = (n <= 5000 && m <= 5000);
if (sub_1_2) {
solve_1_2();
return;
}
solve_3();
cout << '\n';
}
bool testcases = 0;
signed main() {
#ifdef ONLINE_JUDGE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
cin.tie(0) -> sync_with_stdio(0);
int test = 1;
if (testcases) cin >> test;
for (int cs = 1; cs <= test; cs++) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23756 KB |
Output is correct |
2 |
Correct |
10 ms |
23756 KB |
Output is correct |
3 |
Correct |
10 ms |
23752 KB |
Output is correct |
4 |
Correct |
11 ms |
23808 KB |
Output is correct |
5 |
Correct |
9 ms |
23756 KB |
Output is correct |
6 |
Correct |
10 ms |
23756 KB |
Output is correct |
7 |
Correct |
10 ms |
23712 KB |
Output is correct |
8 |
Correct |
10 ms |
23828 KB |
Output is correct |
9 |
Correct |
10 ms |
23816 KB |
Output is correct |
10 |
Correct |
10 ms |
23816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23756 KB |
Output is correct |
2 |
Correct |
10 ms |
23756 KB |
Output is correct |
3 |
Correct |
10 ms |
23752 KB |
Output is correct |
4 |
Correct |
11 ms |
23808 KB |
Output is correct |
5 |
Correct |
9 ms |
23756 KB |
Output is correct |
6 |
Correct |
10 ms |
23756 KB |
Output is correct |
7 |
Correct |
10 ms |
23712 KB |
Output is correct |
8 |
Correct |
10 ms |
23828 KB |
Output is correct |
9 |
Correct |
10 ms |
23816 KB |
Output is correct |
10 |
Correct |
10 ms |
23816 KB |
Output is correct |
11 |
Correct |
14 ms |
23832 KB |
Output is correct |
12 |
Correct |
17 ms |
23884 KB |
Output is correct |
13 |
Correct |
15 ms |
23892 KB |
Output is correct |
14 |
Correct |
20 ms |
23884 KB |
Output is correct |
15 |
Correct |
20 ms |
23956 KB |
Output is correct |
16 |
Correct |
30 ms |
23908 KB |
Output is correct |
17 |
Correct |
24 ms |
23884 KB |
Output is correct |
18 |
Correct |
30 ms |
23884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
470 ms |
28676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
25952 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23756 KB |
Output is correct |
2 |
Correct |
10 ms |
23756 KB |
Output is correct |
3 |
Correct |
10 ms |
23752 KB |
Output is correct |
4 |
Correct |
11 ms |
23808 KB |
Output is correct |
5 |
Correct |
9 ms |
23756 KB |
Output is correct |
6 |
Correct |
10 ms |
23756 KB |
Output is correct |
7 |
Correct |
10 ms |
23712 KB |
Output is correct |
8 |
Correct |
10 ms |
23828 KB |
Output is correct |
9 |
Correct |
10 ms |
23816 KB |
Output is correct |
10 |
Correct |
10 ms |
23816 KB |
Output is correct |
11 |
Correct |
14 ms |
23832 KB |
Output is correct |
12 |
Correct |
17 ms |
23884 KB |
Output is correct |
13 |
Correct |
15 ms |
23892 KB |
Output is correct |
14 |
Correct |
20 ms |
23884 KB |
Output is correct |
15 |
Correct |
20 ms |
23956 KB |
Output is correct |
16 |
Correct |
30 ms |
23908 KB |
Output is correct |
17 |
Correct |
24 ms |
23884 KB |
Output is correct |
18 |
Correct |
30 ms |
23884 KB |
Output is correct |
19 |
Incorrect |
101 ms |
29288 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
23756 KB |
Output is correct |
2 |
Correct |
10 ms |
23756 KB |
Output is correct |
3 |
Correct |
10 ms |
23752 KB |
Output is correct |
4 |
Correct |
11 ms |
23808 KB |
Output is correct |
5 |
Correct |
9 ms |
23756 KB |
Output is correct |
6 |
Correct |
10 ms |
23756 KB |
Output is correct |
7 |
Correct |
10 ms |
23712 KB |
Output is correct |
8 |
Correct |
10 ms |
23828 KB |
Output is correct |
9 |
Correct |
10 ms |
23816 KB |
Output is correct |
10 |
Correct |
10 ms |
23816 KB |
Output is correct |
11 |
Correct |
14 ms |
23832 KB |
Output is correct |
12 |
Correct |
17 ms |
23884 KB |
Output is correct |
13 |
Correct |
15 ms |
23892 KB |
Output is correct |
14 |
Correct |
20 ms |
23884 KB |
Output is correct |
15 |
Correct |
20 ms |
23956 KB |
Output is correct |
16 |
Correct |
30 ms |
23908 KB |
Output is correct |
17 |
Correct |
24 ms |
23884 KB |
Output is correct |
18 |
Correct |
30 ms |
23884 KB |
Output is correct |
19 |
Incorrect |
470 ms |
28676 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |