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 "grader.cpp"
#include "books.h"
#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2 ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
int dp[(1<<20)+5];
void solve(int32_t n, int32_t k, int a, int32_t S) {
int s=0,e = n-1;
while(s<=e){
int mid = (s+e)/2;
int x = skim(mid+1);
if(x >= a)e=mid-1;
else s=mid+1;
}
cout<<s<<endl;
if(s == n)
s--;
int arr[2*k+1][2];
memset(arr,-1,sizeof arr);
for(int i=0;i<k;i++)
arr[i][0] = skim(i+1),arr[i][1] = i+1;
for(int i = s,j = k;i>=max(0ll,s-k);j++,i--)
arr[j][0] = skim(i+1),arr[j][1]=i+1;
int cnt = 0;
for(int i=0;i<k;i++)
cnt += arr[i][0];
if(cnt > 2*a)
impossible();
for(int i=1;i<=(1<<(2*k));i++){
if(__builtin_popcount(i) == k){
cnt=0;
for(int j=0;j<=2*k;j++){
if(i&(1<<j)){
if(arr[j][0] == -1)
goto tooo;
cnt += arr[j][0];
}
}
if(cnt >= a && cnt <= a*2){
vector<int32_t>v;
for(int j=0;j<=2*k;j++){
if(i&(1<<j))
v.push_back(arr[j][1]);
}
answer(v);
}
}
tooo:;
}
impossible();
}
# | 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... |