| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1334293 | enson | A Difficult(y) Choice (BOI21_books) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#include "books.h"
void solve(int N, int K, long long A, int S){
int l = 1; r = N;
int m = (l+r)/2;
vector<long long>F(N, 0);
while (l < r){
m = (l+r)/2;
long long x = skim(m);
F[m] = x;
if (x >= A){
r = m;
} else {
l = m+1;
}
}
if (K > l || l = 1) impossible();
long long ans = 0;
for(int i = 0; i < K-1; i++){
F[i] = skim(i);
ans += F[i];
}
ans += F[l];
if (ans > 2*A) impossible();
F[K-1] = skim(K-1);
ans -= F[l];
ans += F[K-1];
int t = 0;
while (ans < A){
ans -= F[t];
F[l-t-1] = skim(l-t-1);
ans == F[l-t-1];
t++;
if (t >= K) break;
}
if (ans >= A){
vector<int>v;
for(int i = t; i < K; i++)v.push_back(i);
for(int i = l-1; i > l-t-1; i--)v.push_back(i);
} else {
impossible();
}
}
