# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405005 | nicolaalexandra | A Difficult(y) Choice (BOI21_books) | C++14 | 4 ms | 328 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"
#define DIM 100010
using namespace std;
int n,k,s,i;
long long a;
long long v[DIM],d[DIM];
void solve(int n, int k, long long a, int s) {
int i;
long long sum = 0;
for (i=1;i<=k;i++){
d[i] = skim(i);
sum += d[i];
}
if (sum > 2*a){
impossible();
return;
}
vector <int> ans;
if (sum >= a){
for (i=1;i<=k;i++)
ans.push_back(i);
answer(ans);
return;
}
sum -= d[k];
int st = k, dr = n, poz = n+1;
long long val;
while (st <= dr){
int mid = (st + dr) >> 1;
long long nr = skim (mid);
d[mid] = nr;
if (nr >= a){
poz = mid, val = nr;
dr = mid-1;
} else st = mid+1;
}
if (poz <= n && sum + val >= a && sum + val <= 2*a){
ans.push_back(poz);
for (i=1;i<k;i++)
ans.push_back(i);
} else {
sum += d[k];
int st = 1, dr = poz-1;
while (st <= k && sum < a){
sum -= d[st];
if (!d[dr])
d[dr] = skim(dr);
sum += d[dr];
st++, dr--;
}
if (sum < a || sum > 2*a){
impossible();
return;
}
for (i=st;i<=k;i++)
ans.push_back(i);
for (i=dr+1;i<poz;i++)
ans.push_back(i);
}
sort (ans.begin(),ans.end());
answer(ans);
}
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... |