Submission #988973

#TimeUsernameProblemLanguageResultExecution timeMemory
988973MercubytheFirstHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3064 ms22168 KiB
#include <bits/stdc++.h> using ll = long long; #define pb push_back using namespace std; #define CDIV(a, b) ((((a) - (1)) / (b)) + 1) void solve() { int n, Q; cin >> n >> Q; vector<int> v(n + 1); for(int i = 1; i <= n; ++i) { cin >> v[i]; } while(Q--) { int l, r, k; cin >> l >> r >> k; set<int> s; int mx = -1; for(int i = l; i <= r; ++i) { if(!s.empty() and *s.rbegin() > v[i]) { mx = max(mx, v[i] + *s.rbegin()); } s.insert(v[i]); } if(mx > k) { cout << 0 << endl; } else { cout << 1 << endl; } } } signed main() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); // signed t = 0; cin >> t; while(t --> 0) solve(); }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:36:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   freopen("in.txt", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:37:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   freopen("out.txt", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...