Submission #1114333

#TimeUsernameProblemLanguageResultExecution timeMemory
1114333vjudge1Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
100 / 100
1132 ms104144 KiB
#include <bits/stdc++.h> using namespace std; vector<int>st,v,res; void update(int i,int l,int r,int x,int k) { if(l==r) { st[i]=k; return; } int m=(l+r)/2; if(x<=m)update(i*2,l,m,x,k); else update(i*2+1,m+1,r,x,k); st[i]=max(st[2*i],st[2*i+1]); } int gsum(int i,int l,int r,int tl,int tr) { if(l>tr||tl>r||l>r)return 0; if(tl<=l&&r<=tr)return st[i]; int m=(l+r)/2; return max(gsum(2*i,l,m,tl,tr),gsum(i*2+1,m+1,r,tl,tr)); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,m,a,b,c; cin>>n>>m; vector<pair<int,pair<int,int>>>q[n]; res.resize(m); st.resize(4*n+1); for(int i=0;i<n;i++) { cin>>a; v.push_back(a); } for(int i=0;i<m;i++) { cin>>a>>b>>c; q[b-1].push_back({i,{a-1,c}}); } stack<int>s; for(int i=0;i<n;i++) { while(!s.empty()) { if(v[s.top()]<=v[i])s.pop(); else break; } if(!s.empty())update(1,0,n-1,s.top(),v[s.top()]+v[i]); s.push(i); for(int j=0;j<q[i].size();j++) { if(gsum(1,0,n-1,q[i][j].second.first,i)<=q[i][j].second.second)res[q[i][j].first]=1; else res[q[i][j].first]=0; } } for(int i=0;i<m;i++) { cout<<res[i]<<"\n"; } }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int j=0;j<q[i].size();j++)
      |                     ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...