Submission #403387

#TimeUsernameProblemLanguageResultExecution timeMemory
403387NordwayA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms448 KiB
#include <bits/stdc++.h> #include <books.h> #define sz(v) (int)v.size() #define pb push_back using namespace std; typedef long long ll; const int N = 1e5 + 1; bool asked[N]; ll x[N]; ll ask (int i) { if (!i) return 0ll; if (asked[i]) return x[i]; asked[i] = true; x[i] = skim(i); return x[i]; } void solve(int n,int k,ll A,int s){ for (int i = 1; i <= n; i++) { asked[i] = false; } // 1...k (<=10) ll sum = 0; vector <int> ans; for (int i = 1; i <= k; i++) { sum += ask(i); ans.pb(i); if (sum > A + A) impossible(); } if (sum >= A) answer(ans); // x[R] > A (~16-17) int l = k + 1, r = n, R = 0; while (l <= r) { int mid = (l + r) / 2; if(ask(mid) <= A) l = mid + 1; else R = mid, r = mid - 1; } // 1...k-1 + R (0) if (sum - ask(k) + ask(R) >= A && sum - ask(k) + ask(R) <= A + A) { ans.pop_back(); ans.pb(R); answer(ans); } // R...R-k+1 (<=10) if (!R) R = n; else R--; int j = max(R - k + 1, k + 1); for (int i = 1; i <= k; i++) { if (j > R) break; sum -= ask(i); sum += ask(j); ans[i - 1] = j; if (sum >= A && sum <= A + A) 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...