# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581146 | l_reho | A Difficult(y) Choice (BOI21_books) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<long long> vals;
for(int i = 1; i <= N; i++){
long long curr_diff = skim(i);
vals.push_back(curr_diff);
}
ll sum = 0;
deque<int> ans;
vector<int> res;
for(int i = 0; i < K; i++){
ans.push_back(i+1);
sum += vals[i];
}
if(sum >= A && sum <= 2*A){
for(int i = 0; i < K; i++) res.push_back(ans[i]);
answer(res);
}
ans.pop_back();
sum -= vals[K-1];
for(int j = 0; j <= N-K; j++){
for(int i = j+K-1; i < N; i++){
sum += vals[i];
ans.push_back(i+1);
// test
if(sum >= A && sum <= 2*A){
for(int k = 0; k < K; k++) res.push_back(ans[k]);
answer(res);
}
if(sum > 2*A) break;
sum -= vals[i];
ans.pop_back();
}
sum -= vals[j];
ans.pop_front();
sum += vals[j+K-1];
ans.push_back(j+K);
}
impossible();
}