제출 #411544

#제출 시각아이디문제언어결과실행 시간메모리
411544Aldas25A Difficult(y) Choice (BOI21_books)C++14
0 / 100
3 ms200 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; #define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr) #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1, (n)) #define f first #define s second #define pb push_back typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pii> vii; typedef vector<ll> vl; const int MAXN = 1e5 + 100; int n, k, s; ll a; unordered_map<int, ll> saved; ll get (int i) { if (saved[i] > 0)return saved[i]; saved[i] = skim(i); return saved[i]; } void solve(int N, int K, long long A, int S) { n = N; k = K; a = A; s = S; vi ids; FOR(i, 1, k) { ids.pb(i); } if (get(n) >= a && get(k) < a) { int le = 1, ri = n; while (le < ri) { int mid = (le+ri)/2; if (get(mid) >= a) ri = mid; else le = mid+1; } //cout << " le = " << le << endl; ll cur = 0; FOR(i, 1, k-1) cur += get(i); cur += get(le); if (a <= cur && cur <= 2*a) { vi ret; FOR(i, 1, k-1) ret.pb(i); ret.pb(le); answer(ret); return; } FOR(i, max(k+1, le-k), le-1) ids.pb(i); } int sz = (int)ids.size(); FOR(mask, 0, (1<<sz)-1) { ll curS = 0; vi ret; int cnt = 0; FOR(i, 0, sz-1) { if (mask & (1<<i)) { cnt++; curS += get(ids[i]); ret.pb(ids[i]); } } if (cnt == k && a <= curS && curS <= 2*a) { answer(ret); return; } } //answer(ret); 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...