/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const int M = 5005;
const int mod = 1e9 + 7;
int n, m, w[N];
/*
pair < int, int > t[N * 4];
pii combine(pii x, pii y) {
if(x.first >= y.first) return x;
else return y;
}
void build(int v, int l, int r) {
if(l == r) {
t[v] = {a[l], l};
return;
}
int md = (l + r) / 2;
build(v * 2, l, md);
build(v * 2 + 1, md + 1, r);
t[v] = combine(t[v * 2], t[v * 2 + 1]);
}
pii get(int v, int l, int r, int tl, int tr) {
if(l > r) return {0, 0};
if(tl <= l && r <= tr) {
return t[v];
}
if(r < tl || tr < l) return {0, 0};
int md = (l + r) / 2;
return combine(get(v * 2, l, md, tl, tr),
get(v * 2 + 1, md + 1, r, tl, tr));
}*/
main() {
//file("pieaters");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> w[i];
}
//build(1, 1, n);
for(int i = 1; i <= m; i++) {
int l, r, k;
cin >> l >> r >> k;
//pii gt = get(1, 1, n, l, r);
bool ok = 1;
for(int j = l; j <= r; j++) {
for(int kk = j + 1; kk <= r; kk++) {
if(w[j] + w[kk] > k && w[j] > w[kk]) {
ok = 0;
break;
}
}
}
cout << ok << endl;
}
}
Compilation message
sortbooks.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
58 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
11 ms |
336 KB |
Output is correct |
8 |
Correct |
21 ms |
324 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
21 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
11 ms |
336 KB |
Output is correct |
8 |
Correct |
21 ms |
324 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
21 ms |
332 KB |
Output is correct |
11 |
Correct |
383 ms |
388 KB |
Output is correct |
12 |
Execution timed out |
3079 ms |
436 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
10832 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3082 ms |
1656 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 |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
11 ms |
336 KB |
Output is correct |
8 |
Correct |
21 ms |
324 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
21 ms |
332 KB |
Output is correct |
11 |
Correct |
383 ms |
388 KB |
Output is correct |
12 |
Execution timed out |
3079 ms |
436 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
320 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
10 ms |
336 KB |
Output is correct |
7 |
Correct |
11 ms |
336 KB |
Output is correct |
8 |
Correct |
21 ms |
324 KB |
Output is correct |
9 |
Correct |
8 ms |
204 KB |
Output is correct |
10 |
Correct |
21 ms |
332 KB |
Output is correct |
11 |
Correct |
383 ms |
388 KB |
Output is correct |
12 |
Execution timed out |
3079 ms |
436 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |