#include <bits/stdc++.h>
#define S second
#define F first
#define sz size()
#define int long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define yes "YES\n"
#define no "NO\n"
#define ent "\n"
#define give_me_more_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn = 1e6 + 5, mod = 1e9 + 7;
int pref[maxn];
int a[maxn];
void solve(){
int n , q;
cin >> n >> q;
pref[1] = 0;
for(int i = 1;i <= n;i++){
cin >> a[i];
if(i > 1){
pref[i] = pref[i - 1] + (a[i - 1] <= a[i]);
}
}
int mn = *min_element(a + 1,a + 1 + n);
// cout<<mn<<ent;
while(q--){
int l , r , k;
cin >> l >> r >> k;
if(k < mn){
// cout<<pref[r] - pref[l]<<ent;
if(pref[r] - pref[l] == (r - l)){
cout<<1<<ent;
}
else cout<<0<<ent;
continue;
}
int ok = 1;
for(int i = l + 1;i <= r;i++){
for(int j = l;j < i;j++){
if(a[i] + a[j] > k && a[i] < a[j]){
ok = 0;
}
}
}
cout<<ok<<ent;
}
}
signed main(){
give_me_more_speed
int t = 1;
//cin>>t;
for(int i = 1;i <= t;i++){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
15 ms |
2520 KB |
Output is correct |
7 |
Correct |
16 ms |
2520 KB |
Output is correct |
8 |
Correct |
32 ms |
2648 KB |
Output is correct |
9 |
Correct |
11 ms |
2396 KB |
Output is correct |
10 |
Correct |
43 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
15 ms |
2520 KB |
Output is correct |
7 |
Correct |
16 ms |
2520 KB |
Output is correct |
8 |
Correct |
32 ms |
2648 KB |
Output is correct |
9 |
Correct |
11 ms |
2396 KB |
Output is correct |
10 |
Correct |
43 ms |
2396 KB |
Output is correct |
11 |
Correct |
737 ms |
2396 KB |
Output is correct |
12 |
Execution timed out |
3046 ms |
2524 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
348 ms |
18048 KB |
Output is correct |
2 |
Correct |
376 ms |
18300 KB |
Output is correct |
3 |
Correct |
358 ms |
18004 KB |
Output is correct |
4 |
Correct |
366 ms |
18260 KB |
Output is correct |
5 |
Correct |
359 ms |
18000 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3009 ms |
6788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
15 ms |
2520 KB |
Output is correct |
7 |
Correct |
16 ms |
2520 KB |
Output is correct |
8 |
Correct |
32 ms |
2648 KB |
Output is correct |
9 |
Correct |
11 ms |
2396 KB |
Output is correct |
10 |
Correct |
43 ms |
2396 KB |
Output is correct |
11 |
Correct |
737 ms |
2396 KB |
Output is correct |
12 |
Execution timed out |
3046 ms |
2524 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
15 ms |
2520 KB |
Output is correct |
7 |
Correct |
16 ms |
2520 KB |
Output is correct |
8 |
Correct |
32 ms |
2648 KB |
Output is correct |
9 |
Correct |
11 ms |
2396 KB |
Output is correct |
10 |
Correct |
43 ms |
2396 KB |
Output is correct |
11 |
Correct |
737 ms |
2396 KB |
Output is correct |
12 |
Execution timed out |
3046 ms |
2524 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |