/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
void myscan(int& res)
{
int sp=' ';
int ln=10;
int zr='0';
int x;
res=0;
while(1)
{
x=getchar();
if(x<zr || x>(zr+9))
continue;
res+=x-zr;
break;
}
while(1)
{
x=getchar();
if(x<zr || x>(zr+9))
break;
res=res*10+x-zr;
}
//cout<<"!!"<<res<<endl;
}
int n,m,a[1000006];
int ans;
vector<int> g[4*1000006];
int t[4*1000006],mx[4*1000006];
int mergeSerge(vector<int>& a,vector<int>& b,vector<int> &c)
{
int p=0,q=0,d=0;
for(int i=0;i<b.size();i++)
if(b[i]<a.back())
d=a.back()+b[i];
while(p<a.size())
{
while(q<b.size() && b[q]<a[p])
c.PB(b[q++]);
c.PB(a[p++]);
}
while(q<b.size())
c.PB(b[q++]);
return d;
}
void build(int v,int l,int r)
{
if(l==r)
{
t[v]=a[l];
g[v].PB(a[l]);
return;
}
int m=(l+r)/2;
build(v*2,l,m);
build(v*2+1,m+1,r);
mx[v]=mergeSerge(g[v*2],g[v*2+1],g[v]);
mx[v]=max(mx[v],max(mx[v*2],mx[v*2+1]));
t[v]=max(t[v*2],t[v*2+1]);
}
int get(int v,int l,int r,int i,int j,int lmax)
{
if(i>j)
return -1;
if(l==i && r==j)
{
//cout<<"["<<l<<":"<<r<<"]"<<" "<<lmax<<endl;
if(g[v][0]<lmax)
ans=max(ans,lmax+(*(lower_bound(all(g[v]),lmax)-1)));
ans=max(ans,mx[v]);
return t[v];
}
int m=(l+r)>>1;
int p1,p2;
p1=get(v*2,l,m,i,min(j,m),lmax);
lmax=max(lmax,p1);
p2=get(v*2+1,m+1,r,max(m+1,i),j,lmax);
lmax=max(lmax,p2);
return lmax;
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
myscan(a[i]);
build(1,1,n);
while(m--)
{
int l,r,k;
ans=0;
// scanf("%d%d%d",&l,&r,&k);
myscan(l);
myscan(r);
myscan(k);
get(1,1,n,l,r,-1);
//cout<<ans<<endl;
printf("%c\n",(k>=ans)+'0');
}
return 0;
}
/*
3 2
5 4 4
1 3 9
1 3 8
*/
Compilation message
sortbooks.cpp: In function 'void myscan(int&)':
sortbooks.cpp:28:9: warning: unused variable 'sp' [-Wunused-variable]
int sp=' ';
^~
sortbooks.cpp:29:9: warning: unused variable 'ln' [-Wunused-variable]
int ln=10;
^~
sortbooks.cpp: In function 'int mergeSerge(std::vector<int>&, std::vector<int>&, std::vector<int>&)':
sortbooks.cpp:61:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<b.size();i++)
~^~~~~~~~~
sortbooks.cpp:64:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(p<a.size())
~^~~~~~~~~
sortbooks.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(q<b.size() && b[q]<a[p])
~^~~~~~~~~
sortbooks.cpp:70:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(q<b.size())
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
94436 KB |
Output is correct |
2 |
Correct |
88 ms |
94200 KB |
Output is correct |
3 |
Correct |
89 ms |
94328 KB |
Output is correct |
4 |
Correct |
88 ms |
94364 KB |
Output is correct |
5 |
Correct |
90 ms |
94452 KB |
Output is correct |
6 |
Correct |
88 ms |
94384 KB |
Output is correct |
7 |
Correct |
90 ms |
94328 KB |
Output is correct |
8 |
Correct |
89 ms |
94332 KB |
Output is correct |
9 |
Correct |
110 ms |
94332 KB |
Output is correct |
10 |
Correct |
97 ms |
94300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
94436 KB |
Output is correct |
2 |
Correct |
88 ms |
94200 KB |
Output is correct |
3 |
Correct |
89 ms |
94328 KB |
Output is correct |
4 |
Correct |
88 ms |
94364 KB |
Output is correct |
5 |
Correct |
90 ms |
94452 KB |
Output is correct |
6 |
Correct |
88 ms |
94384 KB |
Output is correct |
7 |
Correct |
90 ms |
94328 KB |
Output is correct |
8 |
Correct |
89 ms |
94332 KB |
Output is correct |
9 |
Correct |
110 ms |
94332 KB |
Output is correct |
10 |
Correct |
97 ms |
94300 KB |
Output is correct |
11 |
Correct |
91 ms |
94584 KB |
Output is correct |
12 |
Correct |
107 ms |
95068 KB |
Output is correct |
13 |
Correct |
96 ms |
95188 KB |
Output is correct |
14 |
Correct |
99 ms |
95176 KB |
Output is correct |
15 |
Correct |
98 ms |
95196 KB |
Output is correct |
16 |
Correct |
96 ms |
95096 KB |
Output is correct |
17 |
Correct |
94 ms |
94840 KB |
Output is correct |
18 |
Correct |
94 ms |
95096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3043 ms |
262144 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
351 ms |
111708 KB |
Output is correct |
2 |
Correct |
309 ms |
111700 KB |
Output is correct |
3 |
Correct |
267 ms |
111600 KB |
Output is correct |
4 |
Correct |
324 ms |
111604 KB |
Output is correct |
5 |
Correct |
332 ms |
111568 KB |
Output is correct |
6 |
Correct |
218 ms |
111552 KB |
Output is correct |
7 |
Correct |
216 ms |
111472 KB |
Output is correct |
8 |
Correct |
251 ms |
111420 KB |
Output is correct |
9 |
Correct |
129 ms |
95864 KB |
Output is correct |
10 |
Correct |
249 ms |
111316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
94436 KB |
Output is correct |
2 |
Correct |
88 ms |
94200 KB |
Output is correct |
3 |
Correct |
89 ms |
94328 KB |
Output is correct |
4 |
Correct |
88 ms |
94364 KB |
Output is correct |
5 |
Correct |
90 ms |
94452 KB |
Output is correct |
6 |
Correct |
88 ms |
94384 KB |
Output is correct |
7 |
Correct |
90 ms |
94328 KB |
Output is correct |
8 |
Correct |
89 ms |
94332 KB |
Output is correct |
9 |
Correct |
110 ms |
94332 KB |
Output is correct |
10 |
Correct |
97 ms |
94300 KB |
Output is correct |
11 |
Correct |
91 ms |
94584 KB |
Output is correct |
12 |
Correct |
107 ms |
95068 KB |
Output is correct |
13 |
Correct |
96 ms |
95188 KB |
Output is correct |
14 |
Correct |
99 ms |
95176 KB |
Output is correct |
15 |
Correct |
98 ms |
95196 KB |
Output is correct |
16 |
Correct |
96 ms |
95096 KB |
Output is correct |
17 |
Correct |
94 ms |
94840 KB |
Output is correct |
18 |
Correct |
94 ms |
95096 KB |
Output is correct |
19 |
Correct |
724 ms |
132436 KB |
Output is correct |
20 |
Correct |
734 ms |
132404 KB |
Output is correct |
21 |
Correct |
644 ms |
132220 KB |
Output is correct |
22 |
Correct |
667 ms |
132164 KB |
Output is correct |
23 |
Correct |
634 ms |
132248 KB |
Output is correct |
24 |
Correct |
444 ms |
132076 KB |
Output is correct |
25 |
Correct |
447 ms |
132080 KB |
Output is correct |
26 |
Correct |
523 ms |
132340 KB |
Output is correct |
27 |
Correct |
533 ms |
132320 KB |
Output is correct |
28 |
Correct |
536 ms |
132228 KB |
Output is correct |
29 |
Correct |
532 ms |
132460 KB |
Output is correct |
30 |
Correct |
542 ms |
132384 KB |
Output is correct |
31 |
Correct |
540 ms |
132412 KB |
Output is correct |
32 |
Correct |
551 ms |
132332 KB |
Output is correct |
33 |
Correct |
548 ms |
132348 KB |
Output is correct |
34 |
Correct |
414 ms |
132128 KB |
Output is correct |
35 |
Correct |
405 ms |
132076 KB |
Output is correct |
36 |
Correct |
426 ms |
131980 KB |
Output is correct |
37 |
Correct |
395 ms |
131820 KB |
Output is correct |
38 |
Correct |
406 ms |
132092 KB |
Output is correct |
39 |
Correct |
499 ms |
131056 KB |
Output is correct |
40 |
Correct |
353 ms |
117104 KB |
Output is correct |
41 |
Correct |
522 ms |
130608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
94436 KB |
Output is correct |
2 |
Correct |
88 ms |
94200 KB |
Output is correct |
3 |
Correct |
89 ms |
94328 KB |
Output is correct |
4 |
Correct |
88 ms |
94364 KB |
Output is correct |
5 |
Correct |
90 ms |
94452 KB |
Output is correct |
6 |
Correct |
88 ms |
94384 KB |
Output is correct |
7 |
Correct |
90 ms |
94328 KB |
Output is correct |
8 |
Correct |
89 ms |
94332 KB |
Output is correct |
9 |
Correct |
110 ms |
94332 KB |
Output is correct |
10 |
Correct |
97 ms |
94300 KB |
Output is correct |
11 |
Correct |
91 ms |
94584 KB |
Output is correct |
12 |
Correct |
107 ms |
95068 KB |
Output is correct |
13 |
Correct |
96 ms |
95188 KB |
Output is correct |
14 |
Correct |
99 ms |
95176 KB |
Output is correct |
15 |
Correct |
98 ms |
95196 KB |
Output is correct |
16 |
Correct |
96 ms |
95096 KB |
Output is correct |
17 |
Correct |
94 ms |
94840 KB |
Output is correct |
18 |
Correct |
94 ms |
95096 KB |
Output is correct |
19 |
Execution timed out |
3043 ms |
262144 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |