Submission #553558

#TimeUsernameProblemLanguageResultExecution timeMemory
553558new_accA Difficult(y) Choice (BOI21_books)C++14
100 / 100
1 ms348 KiB
#include<bits/stdc++.h> #include "books.h" #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e18; const ll mod2=998244353; const ll mod=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; ll t[N]; ll que(int a){ if(t[a]) return t[a]; t[a]=skim(a); return t[a]; } void solve(int n,int k,ll a,int s){ int pocz=1,kon=n,sr,res=n+1; while(pocz<=kon){ sr=(pocz+kon)>>1; if(que(sr)>=a) res=sr,kon=sr-1; else pocz=sr+1; } if(res<k){ impossible(); return; } ll last=(res==n+1?INFl:que(res)); ll sum=0; for(int i=1;i<k;i++) sum+=que(i); sum+=last; vi ans; if(sum>=a and sum<=(a<<1LL)){ for(int i=1;i<k;i++) ans.push_back(i); ans.push_back(res); answer(ans); return; } if(res==k){ impossible(); return; } sum-=last; sum+=que(k); ll sum2=0; res--; for(int i=res;i>=res-k+1;i--) sum2+=que(i); if(sum>(a<<1LL) or sum2<a){ impossible(); return; } for(int i=1;i<=k;i++){ int dr=res-i+1; if(dr<=k or sum>=a){ ans.push_back(i); continue; } ans.push_back(dr); sum+=t[dr]-t[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...