#include <bits/stdc++.h>
#define N 1000005
using namespace std;
int a[N];
void solve(){
int n,m;
cin >> n >> m;
for(int i = 1;i<=n;i++){
cin >> a[i];
}
for(int i = 1;i<=m;i++){
int l,r,k;
cin >> l >> r >> k;
set<int> s;
bool ok = 1;
for(int i = r;i>=l;i--){
if(s.size() && *s.begin() < a[i]){
int val = a[i] + *prev(s.lower_bound(a[i]));
if(val > k)
ok = 0;
}
s.insert(a[i]);
}
cout << ok << '\n';
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t=1;
//cin>>t;
while(t--){
solve();
}
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 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 |
11 ms |
340 KB |
Output is correct |
7 |
Correct |
12 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
17 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 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 |
11 ms |
340 KB |
Output is correct |
7 |
Correct |
12 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
17 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
196 ms |
468 KB |
Output is correct |
12 |
Correct |
660 ms |
652 KB |
Output is correct |
13 |
Correct |
803 ms |
732 KB |
Output is correct |
14 |
Correct |
1406 ms |
720 KB |
Output is correct |
15 |
Correct |
1365 ms |
728 KB |
Output is correct |
16 |
Correct |
2045 ms |
684 KB |
Output is correct |
17 |
Correct |
1427 ms |
620 KB |
Output is correct |
18 |
Correct |
70 ms |
416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3037 ms |
34944 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3055 ms |
1384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 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 |
11 ms |
340 KB |
Output is correct |
7 |
Correct |
12 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
17 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
196 ms |
468 KB |
Output is correct |
12 |
Correct |
660 ms |
652 KB |
Output is correct |
13 |
Correct |
803 ms |
732 KB |
Output is correct |
14 |
Correct |
1406 ms |
720 KB |
Output is correct |
15 |
Correct |
1365 ms |
728 KB |
Output is correct |
16 |
Correct |
2045 ms |
684 KB |
Output is correct |
17 |
Correct |
1427 ms |
620 KB |
Output is correct |
18 |
Correct |
70 ms |
416 KB |
Output is correct |
19 |
Execution timed out |
3072 ms |
10932 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 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 |
11 ms |
340 KB |
Output is correct |
7 |
Correct |
12 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
17 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
212 KB |
Output is correct |
11 |
Correct |
196 ms |
468 KB |
Output is correct |
12 |
Correct |
660 ms |
652 KB |
Output is correct |
13 |
Correct |
803 ms |
732 KB |
Output is correct |
14 |
Correct |
1406 ms |
720 KB |
Output is correct |
15 |
Correct |
1365 ms |
728 KB |
Output is correct |
16 |
Correct |
2045 ms |
684 KB |
Output is correct |
17 |
Correct |
1427 ms |
620 KB |
Output is correct |
18 |
Correct |
70 ms |
416 KB |
Output is correct |
19 |
Execution timed out |
3037 ms |
34944 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |