#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
int n,a[maxn],m,b[maxn],c[maxn],d[maxn];
void webbly_abi_spasibo(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
for(int i = 1; i <= m; i++){
cin >> b[i] >> c[i] >> d[i];
}
if(n <= 5000 && m <= 5000){
for(int i = 1; i <= m; i++){
int l = b[i], r = c[i], val = d[i];
int mx = a[l];
bool ok = 1;
for(int j = l + 1; j <= r; j++){
if(mx > a[j]){
if(mx + a[j] > val) {
ok = 0;
break;
}
}
mx = max(mx, a[j]);
}
cout << ok << '\n';
}
}
}
signed main(){
//
// freopen("greedy.in", "r", stdin);
// freopen("greedy.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
int tt = 1;
//cin >> tt;
while(tt--){
webbly_abi_spasibo();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6484 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6484 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6648 KB |
Output is correct |
11 |
Correct |
3 ms |
6900 KB |
Output is correct |
12 |
Correct |
3 ms |
6972 KB |
Output is correct |
13 |
Correct |
3 ms |
6904 KB |
Output is correct |
14 |
Correct |
3 ms |
6748 KB |
Output is correct |
15 |
Correct |
3 ms |
6748 KB |
Output is correct |
16 |
Correct |
10 ms |
6748 KB |
Output is correct |
17 |
Correct |
10 ms |
6748 KB |
Output is correct |
18 |
Correct |
9 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
278 ms |
63364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
30 ms |
12812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6484 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6648 KB |
Output is correct |
11 |
Correct |
3 ms |
6900 KB |
Output is correct |
12 |
Correct |
3 ms |
6972 KB |
Output is correct |
13 |
Correct |
3 ms |
6904 KB |
Output is correct |
14 |
Correct |
3 ms |
6748 KB |
Output is correct |
15 |
Correct |
3 ms |
6748 KB |
Output is correct |
16 |
Correct |
10 ms |
6748 KB |
Output is correct |
17 |
Correct |
10 ms |
6748 KB |
Output is correct |
18 |
Correct |
9 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
54 ms |
21588 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
1 ms |
6484 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6648 KB |
Output is correct |
11 |
Correct |
3 ms |
6900 KB |
Output is correct |
12 |
Correct |
3 ms |
6972 KB |
Output is correct |
13 |
Correct |
3 ms |
6904 KB |
Output is correct |
14 |
Correct |
3 ms |
6748 KB |
Output is correct |
15 |
Correct |
3 ms |
6748 KB |
Output is correct |
16 |
Correct |
10 ms |
6748 KB |
Output is correct |
17 |
Correct |
10 ms |
6748 KB |
Output is correct |
18 |
Correct |
9 ms |
6748 KB |
Output is correct |
19 |
Incorrect |
278 ms |
63364 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |