Submission #415863

#TimeUsernameProblemLanguageResultExecution timeMemory
415863BlagojceA Difficult(y) Choice (BOI21_books)C++14
0 / 100
11 ms200 KiB
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define pb push_back #define st first #define nd second #define pq priority_queue #define all(x) begin(x), end(x) using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pii; const ll inf = 1e18; const int i_inf = 1e9; const ll mod = 1e9+7; mt19937 _rand(time(NULL)); const int mxn = 2e5; #include "books.h" int pref[10]; vector<pair<int,int> > v; void solve(int N, int K, long long A, int S) { fr(i, 0, 10){ pref[i] = skim(i+1); v.pb({pref[i], i}); } if(pref[0] < A){ int k = 0; for(int b = (N+1)/2; b >= 1; b /= 2){ while(b + k < N && skim(b + k + 1) < A) k += b; } for(int i = k; i >= 10 && k - i < 10; i --){ v.pb({skim(i+1), i}); } if(k + 1 < N){ v.pb({skim(k+2), k+1}); } fr(mask, 0, (1<<((int)v.size()))){ if(__builtin_popcount(mask) != S) continue; ll sum = 0; fr(j, 0, (int)v.size()){ if(mask&(1<<j)) sum += v[j].st; } if(A <= sum && sum <= 2*A){ vector<int> sol; fr(j, 0, (int)v.size()){ if(mask&(1<<j))sol.pb(v[j].nd+1); } answer(sol); } } impossible(); } else{ if(S == 1){ answer({1}); } else{ 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...