Submission #1032375

#TimeUsernameProblemLanguageResultExecution timeMemory
1032375Marco_EscandonA Difficult(y) Choice (BOI21_books)C++17
100 / 100
1 ms1364 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const string ny[2] = {"No", "Yes"}; #include"books.h" void solve(int n, int k, long long A, int S) { ll cad[n+4]={ }; ll v[k+2]={ },ac=0; v[k+1]=n+1; vector<ll> asd; for(int i=1; i<=k; i++) { cad[i]=skim(i); v[i]=i; ac+=cad[i]; asd.push_back(i); } for(int i=k; i>0; i--) { if(ac>=A) break; ac-=cad[v[i]]; for(auto j:asd) { if(ac+cad[j]<=2*A&&j<v[i+1]) { v[i]=max(v[i],j); } } ac+=cad[v[i]]; if(ac>=A) break; ac-=cad[v[i]]; ll a=v[i]; ll b=v[i+1]; while(abs(a-b)!=1) { ll m=(a+b)/2; if(cad[m]==0) {cad[m]=skim(m);asd.push_back(m);} if(cad[m]+ac<=2*A) a=m; else b=m; } v[i]=b-1; ac+=cad[v[i]]; } if(ac<A||ac>2*A) { impossible(); return; } vector<int> ans; for(int i=1; i<=k; i++) ans.push_back(v[i]); answer(ans); }
#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...