#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 SequalsN(int n, int k, long long a, int s) {
#define int long long
vector<int> v(n);
for (int i = 0; i < n; ++i) v[i] = skim(i+1);
int lim = 0, cur = 0;
set<int> ans;
while (lim+1 < n and v[lim+1] <= a) lim++;
for (int i = 0; i < k; ++i) ans.insert(i+1), cur += v[i];
auto go = [&] () {
vector<int32_t> resp;
for (auto x : ans) resp.push_back(x);
answer(resp);
};
if (a <= cur and cur <= 2*a) go();
if (lim < k) impossible();
for (int i = k-1; ~i; --i) {
for (int j = i+1; j <= lim-(k-1-i); ++j) {
cur += v[j] - v[j-1];
ans.insert(j+1);
ans.erase(j);
if (a <= cur) go();
}
}
impossible();
#define int int
}
void solve(int n, int k, long long a, int s) {
s = min(s, n);
if (s == n) SequalsN(n, k, a, s);
assert(false);
}
Compilation message (stderr)
books.cpp:39: warning: "int" redefined
39 | #define int int
|
books.cpp:16: note: this is the location of the previous definition
16 | #define int long long
|
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |