Submission #406187

#TimeUsernameProblemLanguageResultExecution timeMemory
406187shenxyA Difficult(y) Choice (BOI21_books)C++17
0 / 100
2 ms200 KiB
#include "books.h" #include <algorithm> #include <vector> using namespace std; /*long long skim(int i){return i;} void answer(vector<int> v){} void impossible(){}*/ void solve(int N, int K, long long A, int S) { if (skim(1) > A) impossible(); int l = 1, r = N; while (l != r) { if (skim((l + r) / 2 + 1) <= A) l = (l + r) / 2 + 1; else r = (l + r) / 2; } vector<long long> x, pos; if (r <= 2 * K) { for (int i = 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i)); } else { for (int i = 1; i <= K; ++i) pos.push_back(i), x.push_back(skim(i)); for (int i = r - K + 1; i <= r; ++i) pos.push_back(i), x.push_back(skim(i)); } if (r != N && r >= K - 1) { long long sum = 0; for (int i = 0; i < K - 1; ++i) sum += x[i]; sum += skim(r + 1); if (sum <= 2 * A) { vector<int> ans; for (int i = 1; i < K; ++i) ans.push_back(i); ans.push_back(r + 1); answer(ans); } } if (r < K) impossible(); long long sum = 0; for (int i = 0; i < K; ++i) sum += x[i]; if (sum > 2 * A) impossible(); if (sum >= A) { vector<int> ans; for (int i = 1; i <= K; ++i) ans.push_back(i); answer(ans); } for (int i = K; i < x.size(); ++i) { sum += x[i] - x[i - K]; if (sum >= A) { vector<int> ans; for (int j = i; j > i - K; --j) ans.push_back(j); answer(ans); } } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (int i = K; i < x.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...