제출 #710400

#제출 시각아이디문제언어결과실행 시간메모리
710400Radin_Zahedi2A Difficult(y) Choice (BOI21_books)C++17
0 / 100
1 ms216 KiB
#include<bits/stdc++.h> #include "books.h" using namespace std; using ll = long long; #define pb push_back #define mp make_pair #define fi first #define se second #define sz(x) (int)x.size() //#define endl '\n' void solve(int n, int k, ll a, int s) { ll begs[k + 1]; ll ends[k + 1]; for (int i = 1; i <= k; i++) { begs[i] = skim(i); } for (int i = 1; i <= k; i++) { ends[i] = skim(n + 1 - i); } for (int i = 2; i <= k; i++) { begs[i] += begs[i - 1]; ends[i] += ends[i - 1]; } if (begs[k] > 2 * a || ends[k] < a) { impossible(); return; } if (begs[k] >= a) { vector<int> v; for (int i = 1; i <= k; i++) { v.pb(i); } answer(v); return; } int cnt = k - 1; for (int i = 0; i < k; i++) { if (begs[i] + ends[k - i] >= a && begs[i + 1] + ends[k - (i + 1)] <= a) { cnt = i; break; } } int l = cnt; int r = n - (k - (cnt + 1)); while (l + 1 != r) { int m = (l + r + 1) / 2; int val = skim(m); if (begs[cnt] + val + ends[k - (cnt + 1)] >= a) { r = m; } else { l = m; } } vector<int> v; for (int i = 1; i <= cnt; i++) { v.pb(i); } v.pb(r); for (int i = n - (k - (cnt + 1)) + 1; i <= n; i++) { v.pb(i); } answer(v); }
#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...