Submission #849569

#TimeUsernameProblemLanguageResultExecution timeMemory
849569ieeA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms1488 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // void solve(int N, int K, long long A, int S) { vector<int> av; for (int i = 1; i <= N; i++) { av.push_back(i); } vector<long long> mem(N + 1, -1); auto query = [&](int x) { if (mem[x] != -1) return mem[x]; return mem[x] = skim(x); }; vector<int> v; long long cursum = 0; while (av.size()) { if (cursum >= A && cursum < A * 2) answer(v); if (v.size() == S) { impossible(); } int i = av.size(), j = 0, keep = 1; while (i >= 0 && j >= 0) { if (i >= (1 << j) && query(av[i - (1 << j)]) > A * 2 - cursum) { i -= (1 << j); } else { keep = -1; } j += keep; } av.resize(i); if (av.empty()) impossible(); v.push_back(av.back()); cursum += query(av.back()); av.pop_back(); if (cursum >= A && cursum < A * 2) answer(v); } impossible(); }

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   if (v.size() == S) {
      |       ~~~~~~~~~^~~~
#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...