Submission #155989

#TimeUsernameProblemLanguageResultExecution timeMemory
155989ASDF123Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
3105 ms48112 KiB
#include <bits/stdc++.h> #define fr first #define sc using namespace std; const int N = (int)1e6 + 5; const int INF = 1e9 + 7; const int MOD = (int)1e9 + 7; int n, l, r, k, tests; int a[N]; void solve() { scanf("%d%d%d", &l, &r, &k); set <int> st; set <int> ::iterator it; bool ok = true; int mn = INF; for (int i = r; i >= l; i--) { if (i == r) { st.insert(a[i]); mn = min(mn, a[i]); continue; } if (mn < a[i]) { it = st.lower_bound(a[i]); it--; if (*it + a[i] > k) { ok = false; break; } } st.insert(a[i]); mn = min(mn, a[i]); } if (ok) { puts("1"); } else { puts("0"); } } main() { scanf("%d%d", &n, &tests); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } while (tests--) { solve(); } }

Compilation message (stderr)

sortbooks.cpp:45:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
sortbooks.cpp: In function 'void solve()':
sortbooks.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &l, &r, &k);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:46:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &tests);
   ~~~~~^~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a[i]);
     ~~~~~^~~~~~~~~~~~~
#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...