D. Multiple Testcases
CF 1342D I'm so
angry, I'm just a ceil, my god, wsm is always like this, I vomit, I'm so sad
Meaning:
Given n, kn, kn , k , givennnn arraysmi m_imi, Request to group them.
Given kkk size arrayci c_ici, Requires that each group is greater than or equal to iiThe number of digits of i is less than or equal toci c_ici.
Find the minimum number of groups anss, and output the numbers allocated in each group.
Idea:
I think about it at the beginning, there is only one differenceceil
First find the minimum grouping number anss: for mmm array sorting,dpi dp_idpiRecord greater than or equal to iiThe number of i , the current anss isceil (dpi / ci) ceil(dp_i/c_i)ceil(dpi/ci) , Take the maximum value of anss
int n;
vector<LL> ans[maxn];
LL m[maxn],c[maxn],dp[maxn],mp[maxn],anss;
int main(){
LL n=lrd(),k=lrd();
anss=0;
for(int i=1;i<=n;i++){
m[i]=lrd();mp[m[i]]++;}
sort(m+1,m+1+n);
for(int i=k;i>=1;i--)dp[i]=dp[i+1]+mp[i];
for(int i=1;i<=k;i++){
c[i]=ird();anss=max(anss,(dp[i]+c[i]-1)/c[i]);}
cout<<anss<<endl;
int nw=0;
for(int i=n;i>=1;i--){
ans[nw].push_back(m[i]);
nw++;
nw%=anss;
}
for(int i=0;i<anss;i++){
cout<<ans[i].size()<<" ";
for(int j=0;j<ans[i].size();j++)
cout<<ans[i][j]<<" ";
cout<<endl;
}
}