Submission #416711

#TimeUsernameProblemLanguageResultExecution timeMemory
416711jainbot27A Difficult(y) Choice (BOI21_books)C++17
0 / 100
3 ms328 KiB
// 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() int n, k, a, s; void solve(int N, int K, ll A, int S){ n=N, k=K, a=A, s=S; assert(n==s); // task is query 40 books and try to see if we can get a set of K books such that A<=\sum<=2A we have K is less than 10 so SMALL // solve subtask by subtask: /* observation, problem has to require BINARY SEARCH subtask 1: we can just like iterte over first 2 books, check which if we have a third one subtask 2: if the last element we take is <=A then if the previous elements are >A, we can find a solution */ vector<ll> x(n); F0R(i, n){ x[i]=skim(i+1); } { ll p=0; F0R(i, k-1) p+=x[i]; FOR(i, k-1, n){ if(p+x[i]>=A&&2*A<=p+x[i]){ vector<int> ans; F0R(i, k-1) ans.pb(i+1); ans.pb(i+1); answer(ans); } } } ll sum=0; F0R(i, k-1) sum+=x[i]; FOR(i, k-1, n){ sum+=x[i]; if(sum>=a&&sum<=2*a){ vector<int> ans; FOR(j, i-k+1, i+1) ans.pb(j+1); answer(ans); } sum-=x[i-k+1]; } impossible(); } // int main(){ // cin.tie(0)->sync_with_stdio(0); // }
#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...