# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
416854 | jainbot27 | A Difficult(y) Choice (BOI21_books) | C++17 | 2 ms | 284 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.
// Difficult(y) Choice
#include <bits/stdc++.h>
#include "books.h"
using namespace std;
using ll=long long;
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ROF(i, a, b) for(int i=b-1; i>=a; i--)
#define F0R(i, n) FOR(i, 0, n)
#define R0F(i, n) ROF(i, 0, n)
#define f first
#define s second
#define pb push_back
#define siz(x) (int)x.size()
const int mxN=1e5+10;
ll memo[20];
void solve(int N, int K, ll A, int S){
FOR(i, 1, K+1) memo[i]=skim(i);
ll sum=0;
FOR(i, 1, K+1) sum+=memo[i];
if(sum>2*A) impossible();
int lo=K, hi=N, ans;
while(lo<=hi){
int mid=(lo+hi)/2;
if(skim(mid)+sum-memo[K]<=2*A){
ans=mid, lo=mid+1;
}
else hi=mid-1;
}
int cur=K;
ROF(i, ans-K+1, ans+1){
sum-=memo[cur--];
sum+=skim(i);
if(sum>=A){
vector<int> res;
FOR(j, i, ans+1) res.pb(j);
FOR(j, 1, cur+1) res.pb(j);
answer(res);
}
}
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... |