제출 #917003

#제출 시각아이디문제언어결과실행 시간메모리
917003NK_A Difficult(y) Choice (BOI21_books)C++17
0 / 100
0 ms344 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) { return; int lo = 0, hi = N - 1; for(int r = 0; r < 18; r++) { if (lo >= hi) break; 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)), --S; // for(auto& p : X) cout << "(" << p.f << ", " << p.s << ") "; // cout << endl; int M = int(size(X)); assert(M <= 2 * K && S >= 0); 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...