Submission #704777

#TimeUsernameProblemLanguageResultExecution timeMemory
704777Chal1shkanA Difficult(y) Choice (BOI21_books)C++14
0 / 100
3 ms208 KiB
# include <bits/stdc++.h> # include "books.h" # define pb push_back # define ff first # define ss second # define nl "\n" # define sz(x) ((int)(x).size()) # define deb(x) cerr << #x << " = " << x << endl; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 1e5 + 25; const ll inf = 1e18 + 0; const ll mod = 1e9 + 123; const ll dx[] = {-1, 1, 0, 0}; const ll dy[] = {0, 0, -1, 1}; using namespace std; map <int, ll> mp; ll pref[maxn]; int ask (int i) { if (mp.count(i)) return mp[i]; else return mp[i] = skim(i); } void solve(int N, int K, long long A, int S) { if (S == N) { for (int i = 1; i <= N; ++i) { ask(i); pref[i] = pref[i - 1] + ask(i); } for (int i = 0; i <= K; ++i) { ll siz = K - i, pos = -1; ll x = A - pref[i]; ll l = i + 1, r = N - siz + 1; while (l <= r) { ll mid = (l + r) >> 1; if (pref[mid + siz - 1] - pref[mid - 1] >= x) { r = mid - 1; pos = mid; } else { l = mid + 1; } } if (pos != -1) { if (pref[pos + siz - 1] - pref[pos - 1] + pref[i] >= A && pref[pos + siz - 1] - pref[pos - 1] + pref[i] <= A * 2) { vector <int> ans; for (ll j = 1; j <= i; ++j) { ans.pb(j); } for (ll j = pos; j <= pos + siz - 1; ++j) { ans.pb(j); } answer(ans); exit(0); } } } } }
#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...