Submission #344099

#TimeUsernameProblemLanguageResultExecution timeMemory
344099NurlykhanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3069 ms8512 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int)1e6 + 10; const int K = 2; int n, m; int w[N]; bool bad[N]; int max_value[N], max_mood[N]; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) { scanf("%d", &w[i]); } for (int i = 0; i < n; i++) { int block_id = i / K; max_value[block_id] = max(max_value[block_id], w[i]); for (int j = i; j < (block_id + 1) * K; j++) { if (w[i] > w[j]) { max_mood[block_id] = max(max_mood[block_id], w[i] + w[j]); } } } while (m--) { int l, r, k; scanf("%d%d%d", &l, &r, &k); --l, --r; int mx = 0, mxx = 0; for (int i = l; i <= r; ) { if (i % K == 0 && i + K - 1 <= r) { mx = max(mx, max_mood[i / K]); if (mxx <= max_value[i / K]) { mxx = max_value[i / K]; } else { mx = max(mx, mxx + max_value[i / K]); } i += K; } else { if (mxx <= w[i]) { mxx = w[i]; } else { mx = max(mx, mxx + w[i]); } i++; } } if (k >= mx) { printf("1\n"); } else { printf("0\n"); } } return 0; }

Compilation message (stderr)

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
sortbooks.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d", &w[i]);
      |         ~~~~~^~~~~~~~~~~~~
sortbooks.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         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...