제출 #933714

#제출 시각아이디문제언어결과실행 시간메모리
933714AtabayRajabliA Difficult(y) Choice (BOI21_books)C++17
45 / 100
1 ms648 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; const int sz = 1e5 + 5; long long q[sz]; long long get(long long x) { if(q[x])return q[x]; return q[x] = skim(x); } void solve(int n, int k, long long a, int s) { long long sum = 0; vector<int> v; for(int i = 1; i <= k; i++) { sum += get(i); v.push_back(i); } if(sum > 2 * a)impossible(); if(a <= sum)answer(v); long long mx = 2 * a - (sum - get(k)); int l = k + 1, r = n, j = n + 1; while(l <= r) { int m = (l + r) >> 1; if(get(m) <= mx)l = m + 1, j = m; else r = m - 1; } if(j == n + 1)impossible(); if(sum - get(k) + get(j) >= a) { v.pop_back(); v.push_back(j); answer(v); } r = j; set<int> cur; for(int i = 1; i <= k; i++)cur.insert(i); for(int i = 1; r > k; i++) { sum -= get(i); cur.erase(i); sum += get(r); cur.insert(r); r--; if(a <= sum && sum <= 2 * a) { vector<int> ans; for(int i : cur)ans.push_back(i); 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...