#include<bits/stdc++.h>
using namespace std;
long long n,m,a[3000006];
//void buildd()
//{
// for(int i=1;i<=n;i++)
// {
// rmx[0][i]=a[i];
// vt[0][i]=i;
// }
// for(int i=1;i<=21;i++)
// {
// for(int j=1;j<=n-(1<<i)+1;j++)
// {
// if(rmx[i-1][j]>=rmx[i-1][j+(1<<(i-1))])
// {
// rmx[i][j]=rmx[i-1][j];
// vt[i][j]=vt[i-1][j];
// }
// else
// {
// rmx[i][j]=rmx[i-1][j+(1<<(i-1))];
// vt[i][j]=vt[i-1][j+(1<<(i-1))];
// }
// }
// }
//}
//pair<int,int> getmx(long long l,long long r)
//{
// long long k=__lg(r-l+1);
// if(rmx[k][l]>=rmx[k][r-(1<<k)+1])
// {
// return {rmx[k][l],vt[k][l]};
// }
// else return {rmx[k][r-(1<<k)+1],vt[k][r-(1<<k)+1]};
//}
//long long get(long long l,long long r,long long w)
//{
// if(l==r)
// {
// if(a[l]<w) return a[l];
// else return -1;
// }
// pair<int,int> p=getmx(l,r);
// if(p.first<w) return p.first;
// long long mid=(l+r)/2;
// return max(get(l,mid,w),get(mid+1,r,w));
//}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen(".inp","r",stdin);
// freopen(".out","w",stdout);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
// buildd();
if(m<=5000)
{
while(m--)
{
long long l,r,k;
cin>>l>>r>>k;
long long mx=a[l],res=0;
for(int i=l+1;i<=r;i++)
{
if(a[i]>=mx)
{
mx=a[i];
}
else
{
res=max(res,mx+a[i]);
}
}
if(res<=k) cout<<1<<"\n";
else cout<<0<<"\n";
}
}
else
{
while(m--)
{
long long l,r,k;
cin>>l>>r>>k;
cout<<0<<"\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
484 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
484 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
472 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
8 ms |
628 KB |
Output is correct |
17 |
Correct |
6 ms |
356 KB |
Output is correct |
18 |
Correct |
9 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
226 ms |
41204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
4708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
484 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
472 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
8 ms |
628 KB |
Output is correct |
17 |
Correct |
6 ms |
356 KB |
Output is correct |
18 |
Correct |
9 ms |
596 KB |
Output is correct |
19 |
Incorrect |
49 ms |
9556 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
484 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
472 KB |
Output is correct |
11 |
Correct |
2 ms |
352 KB |
Output is correct |
12 |
Correct |
4 ms |
604 KB |
Output is correct |
13 |
Correct |
4 ms |
608 KB |
Output is correct |
14 |
Correct |
6 ms |
604 KB |
Output is correct |
15 |
Correct |
6 ms |
604 KB |
Output is correct |
16 |
Correct |
8 ms |
628 KB |
Output is correct |
17 |
Correct |
6 ms |
356 KB |
Output is correct |
18 |
Correct |
9 ms |
596 KB |
Output is correct |
19 |
Incorrect |
226 ms |
41204 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |