#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vi arr;
int main(){
cin>>n>>m;
for(int i = 0; i < n; i++){
int a;
cin>>a;
arr.pb(a);
}
while(m--){
int l, r, k;
cin>>l>>r>>k;
l--; r--;
bool can = true;
set<int> store;
set<int> s;
for(int i = l; i <= r; i++) s.insert(arr[i]);
vi arrr;
for(auto t : s) arrr.pb(t);
int id = arrr.size()-1;
for(int i = r; i >= l; i--){
while(id>=0 && store.find(arrr[id]) != store.end()){
store.erase(arrr[id]);id--;
}
// cout<<i<<endl;
// for(auto t : store)
// cout<<t<<" ";
// cout<<endl;
if(store.size() == 0) store.insert(arr[i]);
else{
if(arr[i] + *store.rbegin() > k){
can = false;
break;
}
else store.insert(arr[i]);
}
}
cout<<can<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
9 ms |
340 KB |
Output is correct |
7 |
Correct |
9 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
9 ms |
340 KB |
Output is correct |
7 |
Correct |
9 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3018 ms |
37088 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3008 ms |
860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
9 ms |
340 KB |
Output is correct |
7 |
Correct |
9 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
9 ms |
340 KB |
Output is correct |
7 |
Correct |
9 ms |
340 KB |
Output is correct |
8 |
Correct |
19 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
212 KB |
Output is correct |
10 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |