| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1333740 | zhehan | A Difficult(y) Choice (BOI21_books) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
//
// --- 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.
//
void solve(int N, int K, long long A, int S) {
// TODO implement this function
vector<int> books(N, 0);
for (int i = 1; i <= n; ++i) {
books[i] = skim(i);
}
int ind =
lower_bound(books.begin(), books.end(), (A + K - 1) / K) - books.begin();
int sum = 0;
vector<int> ans(K, 0);
for (int i = 0; i < K; ++i) {
sum += books[i + ind];
ans[i] = i + ind;
}
int i = K - 1;
while (sum > 2 * A) {
sum -= books[i + ind];
sum += books[ind + i - K];
ans[i] = ind + i - K;
--i;
if(i<0){
impossible();
}
}
answer(ans);
}
