#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#include <functional>
#include <chrono>
#include <cassert>
#include <bitset>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int N = 5e6 + 5;
#define full(a) a.begin(), a.end()
#define eps 1e-9
void solve() {
int n, m; cin >> n >> m;
vector<int> w(n);
for (int i = 0; i < n; i++)cin >> w[i];
while (m--) {
int l, r, k; cin >> l >> r >> k;
l--, r--;
int ans = 1;
set<int> s;
s.insert(w[r]);
for (int i = r - 1; i >= l; i--) {
auto it = s.lower_bound(w[i]);
if (it != s.begin()) {
it--;
if (*it + w[i] > k)ans = 0;
}
s.insert(w[i]);
}
cout << ans << endl;
}
}
int main()
{
//int tc; cin >> tc;while(tc--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
13 ms |
204 KB |
Output is correct |
7 |
Correct |
12 ms |
204 KB |
Output is correct |
8 |
Correct |
18 ms |
204 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
13 ms |
204 KB |
Output is correct |
7 |
Correct |
12 ms |
204 KB |
Output is correct |
8 |
Correct |
18 ms |
204 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
230 ms |
348 KB |
Output is correct |
12 |
Correct |
726 ms |
512 KB |
Output is correct |
13 |
Correct |
899 ms |
524 KB |
Output is correct |
14 |
Correct |
1448 ms |
532 KB |
Output is correct |
15 |
Correct |
1444 ms |
528 KB |
Output is correct |
16 |
Correct |
2351 ms |
584 KB |
Output is correct |
17 |
Correct |
1633 ms |
488 KB |
Output is correct |
18 |
Correct |
129 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3070 ms |
29068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3068 ms |
688 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 |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
13 ms |
204 KB |
Output is correct |
7 |
Correct |
12 ms |
204 KB |
Output is correct |
8 |
Correct |
18 ms |
204 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
230 ms |
348 KB |
Output is correct |
12 |
Correct |
726 ms |
512 KB |
Output is correct |
13 |
Correct |
899 ms |
524 KB |
Output is correct |
14 |
Correct |
1448 ms |
532 KB |
Output is correct |
15 |
Correct |
1444 ms |
528 KB |
Output is correct |
16 |
Correct |
2351 ms |
584 KB |
Output is correct |
17 |
Correct |
1633 ms |
488 KB |
Output is correct |
18 |
Correct |
129 ms |
300 KB |
Output is correct |
19 |
Execution timed out |
3073 ms |
8748 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
13 ms |
204 KB |
Output is correct |
7 |
Correct |
12 ms |
204 KB |
Output is correct |
8 |
Correct |
18 ms |
204 KB |
Output is correct |
9 |
Correct |
9 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Correct |
230 ms |
348 KB |
Output is correct |
12 |
Correct |
726 ms |
512 KB |
Output is correct |
13 |
Correct |
899 ms |
524 KB |
Output is correct |
14 |
Correct |
1448 ms |
532 KB |
Output is correct |
15 |
Correct |
1444 ms |
528 KB |
Output is correct |
16 |
Correct |
2351 ms |
584 KB |
Output is correct |
17 |
Correct |
1633 ms |
488 KB |
Output is correct |
18 |
Correct |
129 ms |
300 KB |
Output is correct |
19 |
Execution timed out |
3070 ms |
29068 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |