题目大意多测。给你个应用程序每一个应用程序都有一个类别类别可以相同。你可以自己定义与的数量分别表示屏幕的数量和每个屏幕的容量你需要把每个应用都放到屏幕上要求每个屏幕只能放一种程序并且数量要么等于要么等于。## 贪心思路定义数组表示应用类型为的数量。首先注意到最大只能是不然就算把最大的单独放到屏幕里也无法满足要求基于次我们发现了一个时间复杂度是的算法。先枚举在枚举所有的检测一下能否满足要求即所有的能否通过屏幕容量为这一条件成立。证明我们发现交上去过了这是为什么呢我们来证明一下。首先这个代码的时间复杂度是的其中是不同的的种类数那最坏情况就是所有都相等这样可以使前半部分最大也就是也就是的了。代码#includebits/stdc.h using namespace std; #define int long long const int N2e65; int T,n,a[N],b[N]; struct node{ int x,id; }; node c[N]; bool flag[N]; bool f(int n,int s){ if(s1) return true; int mi(ns-1)/s; int mxn/(s-1); return mimx; } int ff(int n,int s){ if(s1) return n; return (ns-1)/s; // 最少屏幕数就是ceil(n/s) } signed main(){ scanf(%lld,T); while(T--){ int t0; int miLLONG_MAX; scanf(%lld,n); for(int i1;in;i){ scanf(%lld,a[i]); if(flag[a[i]]0){ flag[a[i]]1; c[t].ida[i]; b[a[i]]t; c[t].x1; }else{ c[b[a[i]]].x; } } for(int j1;jt;j){ mimin(mi,c[j].x); } int resLLONG_MAX; for(int s1;smi1;s){ int ans0; bool flag2true; for(int j1;jt;j){ if(f(c[j].x,s)true){ ansff(c[j].x,s); }else{ flag2false; break; } } if(flag2true) resmin(res,ans); } printf(%lld\n,res); for(int j1;jt;j){ flag[c[j].id]0; b[c[j].id]0; c[j]{0,0}; } } return 0; }