Submission #572073

#TimeUsernameProblemLanguageResultExecution timeMemory
572073HanksburgerHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
100 / 100
865 ms76616 KiB
#include <bits/stdc++.h> using namespace std; vector<pair<pair<int, int>, int> > v[1000005]; int a[1000005], b[1000005]; vector<pair<int, int> > w; bool c[1000005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; for (int i=1; i<=n; i++) cin >> a[i]; for (int i=1; i<=q; i++) { int l, r, x; cin >> l >> r >> x; v[r].push_back({{l, x}, i}); } for (int i=1; i<=n; i++) { while (w.size() && w[w.size()-1].first<=a[i]) w.pop_back(); if (w.size()) { int x=w[w.size()-1].first+a[i]; for (int i=w[w.size()-1].second; i; i-=(i&-i)) b[i]=max(b[i], x); } w.push_back({a[i], i}); for (int j=0; j<v[i].size(); j++) { int mx=0; for (int k=v[i][j].first.first; k<=n; k+=(k&-k)) mx=max(mx, b[k]); c[v[i][j].second]=(mx<=v[i][j].first.second); } } for (int i=1; i<=q; i++) cout << c[i] << '\n'; return 0; }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j=0; j<v[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...