Submission #987249

#TimeUsernameProblemLanguageResultExecution timeMemory
987249VMaksimoski008A Difficult(y) Choice (BOI21_books)C++17
45 / 100
2 ms852 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; using ll = long long; using ull = unsigned long long; map<int, ull> memo; ull ask(int p) { if(memo.count(p)) return memo[p]; return memo[p] = skim(p); } void solve(int N, int K, ll A, int S) { int l=1, r=N-K+1; while(l <= r) { int mid = (l + r) / 2; ull sum = 0; for(int i=mid; i<=mid+K-1; i++) sum += ask(i); if(sum >= A && sum <= 2 * A) { vector<int> ans; for(int i=mid; i<=mid+K-1; i++) ans.push_back(i); answer(ans); } if(sum < A) l = mid + 1; if(sum > 2 * A) r = mid - 1; } l=K, r=N-K+1; int p = -1; while(l <= r) { int mid = (l + r) / 2; if(ask(mid) >= A) p = mid, r = mid - 1; else l = mid + 1; } if(p != -1) { ull sum = ask(p); for(int i=1; i<=K-1; i++) sum += ask(i); if(sum >= A && sum <= 2 * A) { vector<int> ans; for(int i=1; i<=K-1; i++) ans.push_back(i); ans.push_back(p); answer(ans); } } impossible(); return ; }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:22:16: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |         if(sum >= A && sum <= 2 * A) {
      |            ~~~~^~~~
books.cpp:22:28: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |         if(sum >= A && sum <= 2 * A) {
      |                        ~~~~^~~~~~~~
books.cpp:28:16: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   28 |         if(sum < A) l = mid + 1;
      |            ~~~~^~~
books.cpp:29:16: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   29 |         if(sum > 2 * A) r = mid - 1;
      |            ~~~~^~~~~~~
books.cpp:37:21: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   37 |         if(ask(mid) >= A) p = mid, r = mid - 1;
      |            ~~~~~~~~~^~~~
books.cpp:44:16: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   44 |         if(sum >= A && sum <= 2 * A) {
      |            ~~~~^~~~
books.cpp:44:28: warning: comparison of integer expressions of different signedness: 'ull' {aka 'long long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   44 |         if(sum >= A && sum <= 2 * A) {
      |                        ~~~~^~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...