Submission #917001

#TimeUsernameProblemLanguageResultExecution timeMemory
917001NK_A Difficult(y) Choice (BOI21_books)C++17
20 / 100
37 ms600 KiB
// 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; 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)); assert(M <= 2 * K); 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; } assert(int(size(res)) == K); if (A <= sum && sum <= 2LL * A) { answer(res); return; } } impossible(); }
#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...