#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define MASK(i) (1LL << (i))
#define ull unsigned long long
#define ld long double
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define BIT(x , i) ((x >> (i)) & 1)
#define TASK "task"
#define sz(s) (int) (s).size()
using namespace std;
const int mxN = 3e5 + 227;
const int inf = 1e9 + 277;
const int mod = 998244353;
const ll infll = 1e18 + 7;
const int base = 307;
const int LOG = 20;
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
if (a < b) {a = b; return true;} return false;
}
int n, q;
int a[mxN];
bool vis[mxN];
void solve()
{
cin >> n >> q;
for(int i = 1 ; i <= n ; i++) cin >> a[i];
while(q--) {
int l, r, c;
cin >> l >> r >> c;
vector<int> val;
for(int i = l ; i <= r ; i++) val.pb(a[i]);
sort(all(val));
for(int i = l ; i <= r ; i++) vis[i] = false;
bool ok = true;
for(auto it : val) {
int mx = -inf;
for(int i = l ; i <= r ; i++) {
if(vis[i] == true) continue;
if(a[i] == it) {
vis[i] = true;
break;
}
maximize(mx , a[i]);
}
if(it + mx > c) ok = false;
}
if(ok) cout << 1 << endl;
else cout << 0 << endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen(TASK".inp" , "r" , stdin);
//freopen(TASK".out" , "w" , stdout);
int tc = 1;
//cin >> tc;
while(tc--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
30 ms |
340 KB |
Output is correct |
8 |
Correct |
38 ms |
340 KB |
Output is correct |
9 |
Correct |
10 ms |
340 KB |
Output is correct |
10 |
Correct |
33 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
30 ms |
340 KB |
Output is correct |
8 |
Correct |
38 ms |
340 KB |
Output is correct |
9 |
Correct |
10 ms |
340 KB |
Output is correct |
10 |
Correct |
33 ms |
340 KB |
Output is correct |
11 |
Correct |
1032 ms |
588 KB |
Output is correct |
12 |
Execution timed out |
3074 ms |
480 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
29 ms |
5996 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3089 ms |
1712 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 |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
30 ms |
340 KB |
Output is correct |
8 |
Correct |
38 ms |
340 KB |
Output is correct |
9 |
Correct |
10 ms |
340 KB |
Output is correct |
10 |
Correct |
33 ms |
340 KB |
Output is correct |
11 |
Correct |
1032 ms |
588 KB |
Output is correct |
12 |
Execution timed out |
3074 ms |
480 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
7 |
Correct |
30 ms |
340 KB |
Output is correct |
8 |
Correct |
38 ms |
340 KB |
Output is correct |
9 |
Correct |
10 ms |
340 KB |
Output is correct |
10 |
Correct |
33 ms |
340 KB |
Output is correct |
11 |
Correct |
1032 ms |
588 KB |
Output is correct |
12 |
Execution timed out |
3074 ms |
480 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |