제출 #344107

#제출 시각아이디문제언어결과실행 시간메모리
344107NurlykhanHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3058 ms7828 KiB
#include <bits/stdc++.h> using namespace std; const int N = (int)2e5 + 10; const int K = 2; int n, m; int w[N]; bool bad[N]; int max_value[N], max_mood[N]; vector<int> v[N / K]; 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]); v[block_id].push_back(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]); } } } for (int i = 0; i <= (n - 1) / K; i++) { sort(v[i].begin(), v[i].end()); } 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) { int block_id = i / K; mx = max(mx, max_mood[block_id]); int id = lower_bound(v[block_id].begin(), v[block_id].end(), mxx) - v[block_id].begin() - 1; if (id >= 0) { mx = max(mx, mxx + v[block_id][id]); } mxx = max(mxx, max_value[block_id]); 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; }

컴파일 시 표준 에러 (stderr) 메시지

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