| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 401981 | blue | A Difficult(y) Choice (BOI21_books) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "books.h"
#include <vector>
#include <algorithm>
using namespace std;
long long n;
long long k;
long long a;
vector<long long> diff(100001);
vector<int> res;
long long curr_sum = 0;
int L, R;
void res_search(long long l, long long books)
{
// cerr << "rs " << l << ' ' << books << '\n';
res.push_back(l);
curr_sum += diff[l];
if(books-1 == 0)
{
if(a <= curr_sum && curr_sum <= 2*a)
answer(res);
return;
}
for(long long r = l+1; r <= R; r++)
res_search(r, books-1);
}
void binary_search(long long l, long long r)
{
// cerr << "bs " << l << ' ' << r << '\n';
if(l == r)
{
// L = max(1LL, l-k+1);
// R = min(n, r+k);
L = 1;
R = N;
for(long long i = L; i <= R; i++)
diff[i] = skim(i);
res_search(L, k);
impossible();
}
else
{
long long m = (l+r)/2 + 1;
if(k*skim(m) <= a*2)
return binary_search(m, r);
else
return binary_search(l, m-1);
}
}
//books, choice size, limit, skim limit
void solve(int N, int K, long long A, int S)
{
for(int i = 1; i <= N; i++)
skim(i);
n = N;
k = K;
a = A;
binary_search(1LL, n);
}
