제출 #594962

#제출 시각아이디문제언어결과실행 시간메모리
594962Do_you_copyA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms256 KiB
#include <bits/stdc++.h> #include "books.h" #define taskname "test" #define fi first #define se second #define pb push_back #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using ll = long long; using pii = pair <ll, ll>; using pil = pair <ll, ll>; using pli = pair <ll, ll>; using pll = pair <ll, ll>; using ull = unsigned ll; ll min(const ll &a, const ll &b){ return (a < b) ? a : b; } ll max(const ll &a, const ll &b){ return (a > b) ? a : b; } //const ll Mod = 1000000009; //const ll Mod2 = 999999999989; //only use when required const ll maxN = 1e5 + 1; ll n, k, a, s; vector <pll> tem; vector <int> ans; void solve(int N, int K, ll A, int S){ n = N; k = K; a = A; s = S; ll sum = 0; for (ll i = 1; i <= k; ++i){ tem.pb({i, skim(i)}); sum += tem.back().se; } if (sum > 2 * a) impossible(); if (a <= sum && sum <= 2 * a){ for (auto i: tem) ans.pb(i.fi); answer(ans); } ll l = 1, r = n; while (l <= r){ ll mid = (l + r) / 2; if (skim(mid) >= a) r = mid - 1; else l = mid + 1; } if (r <= k) impossible(); ++r; if (r <= n){ sum = skim(r); for (ll i = 0; i < k - 1; ++i) sum += tem[i].se; if (sum <= 2 * a){ for (ll i = 1; i < k; ++i) ans.pb(i); ans.pb(r); answer(ans); } } --r; if (r == k) impossible(); sum = 0; ll atr = skim(r); for (ll i = 1; i < k; ++i) sum += tem[i].se; if (sum + atr >= a){ for (ll i = 2; i <= k; ++i) ans.pb(i); ans.pb(r); answer(ans); } tem.pb({r, atr}); sum = atr; ans.pb(r); for (ll i = r - 1; i > max(k, r - k) && sum < a; --i){ tem.pb({i, skim(i)}); ans.pb(i); sum += tem.back().se; } if (sum < a) impossible(); int tt = ans.size(); for (ll i = 1; i <= k - tt; ++i){ ans.pb(i); } answer(ans); }
#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...