Submission #1183826

#TimeUsernameProblemLanguageResultExecution timeMemory
1183826asdfghjkHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
17 / 100
3093 ms23592 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]; } 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'; } } main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

sortbooks.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   57 | 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...