正文
增加 2 行删除 2 行
43 行未改动4445464748495051525 行未改动5859606162636465667 行未改动43 行未改动```cppconst int N=1e7+100;const int M=1e5+100;long long ans;int n;int a[N],cnt[M];//桶queue<long long> q1,q2;inline long long get_first(){if (q2.empty()||(!q1.empty()&&q1.front()<q2.front())){long long x=q1.front();q1.pop();return x;}5 行未改动for(int i=1;i<=n;i++)cnt[a[i]=read()]++;for(int i=1;i<=100000;i++)for(int j=1;j<=cnt[i];j++)q1.push(i);//O(N)的桶排for(register int i=1;i<n;i++){long long x=get_first();long long y=get_first();ans+=x+y;q2.push(x+y);7 行未改动43 行未改动4445464748495051525 行未改动5859606162636465667 行未改动43 行未改动```cppconst int N=1e7+100;const int M=1e5+100;long long ans;int n;int a[N],cnt[M];//桶queue<long long> q1,q2;inline long long get_first(){if (q2.empty()||(!q1.empty()&&q1.front()<q2.front())){long long x=q1.front();q1.pop();return x;}5 行未改动for(int i=1;i<=n;i++)cnt[a[i]=read()]++;for(int i=1;i<=100000;i++)for(int j=1;j<=cnt[i];j++)q1.push(i);//O(N)的桶排for(register int i=1;i<n;i++){long long x=get_first();long long y=get_first();ans+=x+y;q2.push(x+y);7 行未改动