#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;
using ll = long long;
namespace {
const int MXN = 10;
int n, k, s;
ll a;
int b;
vector<int> v;
ll l[MXN], r[MXN];
int BSH(int l, int r, int b) {
while (l + 1 < r) {
int mid = (l + r) >> 1;
(skim(mid) >= b ? r : l) = mid;
}
return r;
}
void SOLVE() {
b = BSH(0, n + 1, a);
if (b < k) {
assert(false);
impossible();
return;
}
FOR(i, 0, k) l[i] = skim(i + 1);
if (b != n + 1) {
ll c = skim(b);
ll acc = 0;
FOR(i, 0, k - 1) acc += l[i];
acc += c;
if (acc <= 2 * a) {
FOR(i, 1, k) v.push_back(i);
v.push_back(b);
answer(v);
return;
}
}
if (b == k) {
impossible();
return;
}
FOR(i, 0, k) r[i] = skim(b - k + i);
ll acc = 0;
FOR(i, 0, k) acc += r[i];
if (acc < a) {
impossible();
return;
}
if (acc <= 2 * a) {
FOR(i, 0, k) v.push_back(b - k + i);
answer(v);
return;
}
FOR(i, 0, k) {
acc -= r[i];
acc += l[i];
if (acc <= 2 * a) {
FOR(j, 0, i + 1) v.push_back(j);
FOR(j, i + 1, k) v.push_back(b - k + j);
answer(v);
return;
}
}
impossible();
}
}
void solve(int n, int k, ll a, int s) {
::n = n;
::k = k;
::a = a;
::s = s;
SOLVE();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
600 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |