#include<iostream>
#include<cstring>
#define endl '\n'
using namespace std;
long long a[100003],d[100003],used[5002];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n,m,l,r,k,lpr=0,rpr,i,j;
bool p;
cin>>n>>m;rpr=n-1;
for(i=0;i<n;i++)
{
cin>>d[i];
}
for(i=0;i<m;i++)
{
cin>>l>>r>>k;
l--;r--;
for(j=lpr;j<=rpr;j++)
{
a[j]=d[j];
}
lpr=l;rpr=r;
p=true;
while(p)
{
p=false;
for(j=l;j<r;j++)
{
if(a[j]>a[j+1]&&a[j]+a[j+1]<=k){swap(a[j],a[j+1]);p=true;}
else if(a[j]>a[j+1]&&a[j]+a[j+1]>k){p=false;break;}
}
}
if(l==r ){cout<<1<<endl;continue;}
bool t=false;
for(j=l+1;j<=r;j++)
{
if(a[j]<a[j-1]){cout<<0<<endl;t=true;break;}
}
if(!t)cout<<1<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
8 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
39 ms |
492 KB |
Output is correct |
14 |
Correct |
110 ms |
620 KB |
Output is correct |
15 |
Correct |
12 ms |
620 KB |
Output is correct |
16 |
Execution timed out |
3066 ms |
492 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
3692 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3062 ms |
1900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
8 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
39 ms |
492 KB |
Output is correct |
14 |
Correct |
110 ms |
620 KB |
Output is correct |
15 |
Correct |
12 ms |
620 KB |
Output is correct |
16 |
Execution timed out |
3066 ms |
492 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
17 ms |
364 KB |
Output is correct |
9 |
Correct |
2 ms |
364 KB |
Output is correct |
10 |
Correct |
2 ms |
364 KB |
Output is correct |
11 |
Correct |
8 ms |
492 KB |
Output is correct |
12 |
Correct |
21 ms |
492 KB |
Output is correct |
13 |
Correct |
39 ms |
492 KB |
Output is correct |
14 |
Correct |
110 ms |
620 KB |
Output is correct |
15 |
Correct |
12 ms |
620 KB |
Output is correct |
16 |
Execution timed out |
3066 ms |
492 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |