This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
#define nl '\n'
#define f first
#define s second
#define mp make_pair
#define pb push_back
using ll = long long;
template<class T> using V = vector<T>;
using vi = V<int>;
using pl = pair<ll, ll>;
using vpl = V<pl>;
// g++-13 A.cpp grader.cpp
void solve(int N, int K, ll A, int S) {
int lo = 0, hi = N - 1;
while(lo < hi) {
int mid = (lo + hi) / 2; --S;
if (skim(mid + 1) >= A) hi = mid;
else lo = mid + 1;
}
lo = min(N - 1, lo);
set<int> look;
for(int i = 0; i < K; i++) look.insert(i), look.insert(lo - i);
vpl X; for(auto& i : look) X.pb(mp(skim(i + 1), i));
// for(auto& p : X) cout << "(" << p.f << ", " << p.s << ") ";
// cout << endl;
int M = int(size(X));
for(int msk = 0; msk < (1 << M); msk++) {
if (__builtin_popcount(msk) != K) continue;
ll sum = 0; vi res; for(int i = 0; i < M; i++) if ((msk >> i) & 1) {
res.pb(X[i].s + 1);
sum += X[i].f;
}
if (A <= sum && sum <= 2 * A) {
answer(res); return;
}
}
impossible();
}
# | 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... |