Submission #673685

#TimeUsernameProblemLanguageResultExecution timeMemory
673685stanislavpolynA Difficult(y) Choice (BOI21_books)C++17
100 / 100
2 ms1104 KiB
#include <bits/stdc++.h> #include "books.h" #define fr(i, a, b) for (int i = (a); i <= (b); i++) #define rf(i, a, b) for (int i = (a); i >= (b); i--) #define fe(x, y) for (auto& x : y) #define fi first #define se second #define pb push_back #define mp make_pair #define mt make_tuple #define pw(x) (1LL << (x)) #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() using namespace std; mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define fbo find_by_order #define ook order_of_key template <typename T> bool umn(T& a, T b) { return a > b ? a = b, 1 : 0; } template <typename T> bool umx(T& a, T b) { return a < b ? a = b, 1 : 0; } using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using ve = vector<T>; const int N = 1e5 + 5; ll what[N]; ll get(int i) { if (what[i]) { return what[i]; } else { return what[i] = skim(i); } } void solve(int N, int K, long long A, int S) { fill(what + 1, what + 1 + N, 0); int l = 1; int r = N; while (l < r) { int mid = l + ((r - l) >> 1); if (get(mid) >= A) { r = mid; } else { l = mid + 1; } } { ll sum = 0; sum += get(l); if (sum < A) l++; if (sum >= A && l > K - 1) { fr (i, 1, K - 1) sum += get(i); if (sum <= 2 * A) { ve<int> ans; fr (i, 1, K - 1) ans.pb(i); ans.pb(l); answer(ans); } } } fr (i, 1, K) { what[i] = get(i); } fr (i, max(1, l - K), l - 1) { what[i] = get(i); } ve<pll> v; fr (i, 1, N) { if (what[i]) { v.pb({what[i], i}); } } fr (i, 0, sz(v) - K) { ll sum = 0; fr (j, i, i + K - 1) { sum += v[j].fi; } if (sum >= A && sum <= 2 * A) { ve<int> ans; fr (j, i, i + K - 1) { ans.pb(v[j].se); } answer(ans); } } 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...