Submission #734288

#TimeUsernameProblemLanguageResultExecution timeMemory
734288TheSahibA Difficult(y) Choice (BOI21_books)C++17
10 / 100
2 ms304 KiB
#include "books.h" #include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; map<int, ll> mp; ll get(int pos){ if(mp.find(pos) != mp.end()) return mp[pos]; return mp[pos] = skim(pos); } void solve(int N, int K, long long A, int S) { int l = K, r = N; while(l <= r){ int mid = (l + r) / 2; ll a = 0; vector<int> ans; for(int i = mid - K + 1; i <= mid; i++){ ans.push_back(i); a += get(i); } if(A <= a && a <= 2 * A){ answer(ans); return; } else if(a < A){ l = mid + 1; } else if(2 * A < a){ r = mid - 1; } } l = 1, r = N; int a = -1; vector<int> ans(1); while(l <= r){ int mid = (l + r) / 2; if(get(mid) >= A){ r = mid - 1; a = get(mid); ans[0] = mid; } else{ l = mid + 1; } } if(a == -1){ impossible(); return; } for(int i = 1; i <= K; i++){ if(i == ans[0]){ impossible(); return; } ans.push_back(i); a += get(i); } if(A <= a && a <= 2 * A){ answer(ans); } else{ 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...