Submission #810803

#TimeUsernameProblemLanguageResultExecution timeMemory
810803laurasofiaA Difficult(y) Choice (BOI21_books)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include "books.h" #define FOR(i,a,b) for(int i=a;i<b;i++) #define lli long long int #define vv vector<lli> #define pr pair<int,int> #define print(a) cout<<a<<endl #define f first #define s second 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. // bool check(lli sum, lli A){ return (sum>=A && sum<=2*A); } void solve(int N, int K, long long A, int S) { vector<int> res; vv one; lli sum=0; FOR(i,0,K){ one.push_back(skim(i+1)); sum+=one[i]; } if (sum>=A && sum<=2*A){ FOR(i,1,K+1)res.push_back(i); answer(res);return; } if (sum>2*A){ impossible();return; } int l=1; int r=N; long long a; while(l+1<r){ int m=(l+r)>>1; a=skim(m); if (A<a)r=m; else l=m; } if (skim(l)>=A)r=l; a=skim(r); if (r<K){ impossible(); return; } if (check(sum+a-one.back(),A)){ FOR(i,1,K+1)res.push_back(i); res[K-1]=r; answer(res);return; } vv two; sum=0; FOR(i,r-K,r){ lli a=skim(i); two.push_back(a); sum+=a; } if (sum>=A && sum<=2*A){ FOR(i,r-K,r)res.push_back(i); answer(res);return; } FOR(i,1,K+1)res.push_back(i); FOR(i,0,K){ res[i]=r-K+i; sum+=two[i]-one[i]; if (check(sum,A)){ answer(res);return; } } impossible(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...