# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088978 | Piokemon | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 432 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) {
int pocz,kon,srod;
pocz=1;
kon=N;
while(pocz<kon){
srod=(pocz+kon)/2;
if (skim(srod)>=A)kon=srod;
else pocz=srod+1;
}
if (pocz<=K-1)impossible();
long long int wart = skim(pocz);
vector<long long> val;
vector<int> ind;
for (int x=1;x<=min(K,pocz-1);x++)val.push_back(skim(x));
for (int x=max(K+1,pocz-K);x<pocz;x++)val.push_back(skim(x));
for (int x=1;x<=min(K,pocz-1);x++)ind.push_back(x);
for (int x=max(K+1,pocz-K);x<pocz;x++)ind.push_back(x);
long long suma=0;
for (int x=0;x<K-1;x++)suma+=val[x];
suma+=wart;
if (A<=suma && suma<=2*A){
vector<int> odp;
for (int x=0;x<K-1;x++)odp.push_back(ind[x]);
odp.push_back(pocz);
answer(odp);return;
}
suma=0;
for (int x=0;x<K;x++)suma+=val[x];
for (int x=K;x<val.size();x++){
if (A<=suma && suma<=2*A){
vector<int> odp;
for (int y=x-K;y<x;y++)odp.push_back(ind[y]);
answer(odp); return;
}
suma+=val[x];
suma-=val[x-K];
}
if (A<=suma && suma<=2*A){
vector<int> odp;
for (int y=val.size()-K;y<val.size();y++)odp.push_back(ind[y]);
answer(odp); return;
}
impossible();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |