Submission #1190969

#TimeUsernameProblemLanguageResultExecution timeMemory
1190969lovrotHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++20
17 / 100
1857 ms67888 KiB
#include <cstdio> #include <algorithm> #include <set> #define deb(...) fprintf(stderr, __VA_ARGS__) using namespace std; const int N = 5e3 + 10; int w[N]; int mx[N][N]; int main() { int n, m; scanf("%d%d", &n, &m); for(int i = 0; i < n; ++i) { scanf("%d", w + i); set<int> s; for(int j = i; j >= 0; --j) { s.insert(w[j]); mx[j][i] = mx[j + 1][i]; auto it = s.lower_bound(w[j]); if(it != s.begin()) { mx[j][i] = max(mx[j][i], w[j] + *prev(it)); } } } for(; m--; ) { int l, r, k; scanf("%d%d%d", &l, &r, &k); printf("%d\n", mx[l - 1][r - 1] <= k); } return 0; }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d%d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:18:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |                 scanf("%d", w + i);
      |                 ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:31:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |                 scanf("%d%d%d", &l, &r, &k);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...