#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve(long long int w[], int &n);
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
long long int w[n+1];
w[0] = 0;
for (int i = 1; i <=n; i++)
cin >> w[i];
for (int i = 0; i < m; i++)
solve(w, n);
}
void solve(long long int w[], int &n)
{
int l, r, k;
cin >> l >> r >> k;
long long int sum = 0;
for (int i=l; i<r; i++)
for (int j=i+1; j<=r; j++)
if (w[i]>w[j])
sum = max( sum, (w[i]+w[j]) );
cout << (sum<=k?1:0) << endl;
}
# |
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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
25 ms |
204 KB |
Output is correct |
7 |
Correct |
28 ms |
320 KB |
Output is correct |
8 |
Correct |
34 ms |
316 KB |
Output is correct |
9 |
Correct |
13 ms |
320 KB |
Output is correct |
10 |
Correct |
28 ms |
204 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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
25 ms |
204 KB |
Output is correct |
7 |
Correct |
28 ms |
320 KB |
Output is correct |
8 |
Correct |
34 ms |
316 KB |
Output is correct |
9 |
Correct |
13 ms |
320 KB |
Output is correct |
10 |
Correct |
28 ms |
204 KB |
Output is correct |
11 |
Correct |
1162 ms |
500 KB |
Output is correct |
12 |
Execution timed out |
3030 ms |
324 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3052 ms |
8264 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3061 ms |
1604 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 |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
25 ms |
204 KB |
Output is correct |
7 |
Correct |
28 ms |
320 KB |
Output is correct |
8 |
Correct |
34 ms |
316 KB |
Output is correct |
9 |
Correct |
13 ms |
320 KB |
Output is correct |
10 |
Correct |
28 ms |
204 KB |
Output is correct |
11 |
Correct |
1162 ms |
500 KB |
Output is correct |
12 |
Execution timed out |
3030 ms |
324 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 |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
25 ms |
204 KB |
Output is correct |
7 |
Correct |
28 ms |
320 KB |
Output is correct |
8 |
Correct |
34 ms |
316 KB |
Output is correct |
9 |
Correct |
13 ms |
320 KB |
Output is correct |
10 |
Correct |
28 ms |
204 KB |
Output is correct |
11 |
Correct |
1162 ms |
500 KB |
Output is correct |
12 |
Execution timed out |
3030 ms |
324 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |