제출 #950004

#제출 시각아이디문제언어결과실행 시간메모리
950004PringA Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> #include "books.h" using namespace std; using ll = long long; #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) // // --- Sample implementation for the task books --- // // To compile this program with the sample grader, place: // books.h books_sample.cpp sample_grader.cpp // in a single folder and run: // g++ books_sample.cpp sample_grader.cpp // in this folder. // const int MXN = 100005; ll h[MXN]; int BSH(int l, int r, ll a) { while (l + 1 < r) { int mid = (l + r) >> 1; (skim(mid) >= a ? r : l) = mid; } return r; } void solve(int n, int k, ll a, int s) { FOR(i, 1, k + 1) h[i] = skim(i); int aa = BSH(0, n + 1, a); if (aa != n + 1) { ll val = skim(aa); ll ans = 0; FOR(i, 1, k) ans += h[i]; ans += val; if (ans <= 2 * a) { vector<int> v; FOR(i, 1, k) v.push_back(i); v.push_back(aa); answer(v); return; } } ll ans = 0; FOR(i, 1, k + 1) ans += h[i]; if (ans <= a * 2) { vector<int> v; FOR(i, 1, k + 1) v.push_back(i); answer(v); } for (int i = k; i > 0; i--) { int id = aa - (k - i) - 1; h[id] = skim(id); ans -= h[k]; ans += h[id]; if (ans >= a) { ans -= h[k]; int bb = BSH(k - 1, id, a - ans); vector<int> v; FOR(j, 1, i) v.push_back(j); v.push_back(bb); // FOR(j, i + 2, k + 1) v.push_back(aa - k + j - 1); FOR(j, id + 1, aa) v.push_back(j); answer(v); } } 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...