Submission #1183829

#TimeUsernameProblemLanguageResultExecution timeMemory
1183829asdfghjkHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
30 / 100
870 ms33780 KiB
#include <bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() #define F first #define S second #define con continue using namespace std; typedef long long ll; typedef double db; typedef long double ld; const ll N = 1e6 + 5; const ll inf = 1e9; const ll INF = 1e18; const ll MOD = 1e9 + 7; ll a[N],b[N],c[N]; void solve(){ int n,m;cin >> n >> m; for(int i= 1;i <= n;i++){ cin >> a[i]; } if(max(n,m) <= 5000){ while(m--){ int l,r,k;cin >> l >> r >> k; int d = (r - l + 1); for(int i = 1;i <= d;i++){ b[i] = a[l + (i - 1)]; c[i] = a[l + (i - 1)]; } int mx = 0; set <int> s; s.clear(); s.insert(b[d]); bool can = 1; for(int i = d-1;i > 0;i--){ if(*s.begin() >= b[i]){ s.insert(b[i]); con; } // *s.begin() > a[i] ll x = 0; if(*s.rbegin() < b[i]){ x = *s.rbegin(); } else{ auto it = s.lower_bound(b[i]); it--; x = *it; } if(x + b[i] > k){ can =0; break; } s.insert(b[i]); } cout << can << '\n'; } return; } set <int> pos; pos.clear(); for(int i =1;i < n;i++){ if(a[i] > a[i+1]){ pos.insert(i); } } while(m--){ int l,r,k;cin >> l >> r >> k; if(pos.size() == 0){ cout << "1\n"; con; } int x = *pos.lower_bound(l); if(x < r){ cout << "0\n"; } else cout << "1\n"; } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

sortbooks.cpp:79:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   79 | main(){
      | ^~~~
#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...