# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
865831 | AbdelmagedNour | A Difficult(y) Choice (BOI21_books) | C++17 | 1 ms | 864 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;
typedef long long ll;
ll a[100005];
ll ask(int i){
if(!a[i])a[i]=skim(i);
return a[i];
}
ll Sum(vector<int>v,int l,int r){
ll res=0;
for(int i=l;i<=r;i++)res+=ask(v[i]);
return res;
}
void solve(int N, int K, long long A, int S) {
int l=0;
for(int i=17;i>=0;i--){
int nxt=l+(1<<i);
if(nxt<=N&&ask(nxt)<=A)l=nxt;
}
if(l<=K-2)return impossible();
vector<int>v;
ll sum=0;
for(int i=1;i<=K-1;i++)v.push_back(i),sum+=ask(i);
if(l<N){
v.push_back(l+1);
sum+=ask(l+1);
if(A<=sum&&sum<=2*A)return answer(v);
}
if(l<K)return impossible();
vector<int>arr;
for(int i=1;i<=K;i++)arr.push_back(i),arr.push_back(l-K+i);
sort(arr.begin(),arr.end());
arr.erase(unique(arr.begin(),arr.end()),arr.end());
for(int i=K-1;i<arr.size();i++){
if(A<=Sum(arr,i-K+1,i)&&Sum(arr,i-K+1,i)<=2*A){
return answer(vector<int>(arr.begin()+i-K+1,arr.begin()+i+1));
}
}
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... |