Submission #447471

#TimeUsernameProblemLanguageResultExecution timeMemory
447471prvocisloA Difficult(y) Choice (BOI21_books)C++17
100 / 100
2 ms1032 KiB
#include <bits/stdc++.h> #include "books.h" typedef long long ll; using namespace std; vector<ll> b; ll query(int i) { if (b[i] == -1) b[i] = skim(i+1); return b[i]; } void solve(int n, int k, ll a, int s) { b.assign(n, -1); int lo = 0, hi = n; while (lo < hi) { int mid = (lo+hi)/2; if (query(mid) >= a) hi = mid; else lo = mid + 1; } int m = lo; if (lo != n) { ll sum = query(m); for (int i = 0; i < k-1; i++) sum += query(i); if (a <= sum && sum <= 2*a) { vector<int> v; for (int i = 0; i < k-1; i++) v.push_back(i+1); v.push_back(m+1); answer(v); return; } } vector<pair<ll, int> > v; for (int i = 0; i < min(k, m); i++) v.push_back({query(i), i}); for (int i = max(0, m-k); i < m; i++) v.push_back({query(i), i}); sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); for (int i = 0; i+k-1 < v.size(); i++) { ll sum = 0; vector<int> in; for (int j = i; j < i+k; j++) { sum += v[j].first; in.push_back(v[j].second+1); } if (a <= sum && sum <= 2*a) answer(in); } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:42:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for (int i = 0; i+k-1 < v.size(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...