#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
using namespace std;
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
const int N = 3e5 + 7;
const int M = 1e9 + 7;
const int FFTM = 998244353;
int n, m, x[N], l, r, k, y;
int dp[404][404][404];
inline int s(int i, int j){
return x[j] - x[i];
}
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef Estb_probitie
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cin >> n >> m;
int a[n];
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < m; ++i)
{
int l, r, k;
cin >> l >> r >> k;
--l, --r;
int mx = 0;
int ans = 0;
for (int i = l; i <= r; ++i)
{
if (mx > a[i])
ans = max(ans, mx + a[i]); else
mx = a[i];
}
// cout<<ans<<" "<<k<<endl;
if (ans <= k)
cout<<1<<'\n'; else cout << 0<<'\n';
}
}
Compilation message
sortbooks.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
8 ms |
504 KB |
Output is correct |
13 |
Correct |
9 ms |
504 KB |
Output is correct |
14 |
Correct |
12 ms |
504 KB |
Output is correct |
15 |
Correct |
13 ms |
504 KB |
Output is correct |
16 |
Correct |
17 ms |
504 KB |
Output is correct |
17 |
Correct |
13 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3021 ms |
4364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2343 ms |
1056 KB |
Output is correct |
2 |
Execution timed out |
3032 ms |
2188 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
8 ms |
504 KB |
Output is correct |
13 |
Correct |
9 ms |
504 KB |
Output is correct |
14 |
Correct |
12 ms |
504 KB |
Output is correct |
15 |
Correct |
13 ms |
504 KB |
Output is correct |
16 |
Correct |
17 ms |
504 KB |
Output is correct |
17 |
Correct |
13 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
376 KB |
Output is correct |
19 |
Execution timed out |
3014 ms |
5156 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
504 KB |
Output is correct |
12 |
Correct |
8 ms |
504 KB |
Output is correct |
13 |
Correct |
9 ms |
504 KB |
Output is correct |
14 |
Correct |
12 ms |
504 KB |
Output is correct |
15 |
Correct |
13 ms |
504 KB |
Output is correct |
16 |
Correct |
17 ms |
504 KB |
Output is correct |
17 |
Correct |
13 ms |
504 KB |
Output is correct |
18 |
Correct |
17 ms |
376 KB |
Output is correct |
19 |
Execution timed out |
3021 ms |
4364 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |