请问大佬为什么全Wa,非加强版已经AC了
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e7 + 7;
const ll M = 1e5 + 5;
ll n, buc[M], ans;
queue<ll>q1, q2;
ll rd() {
ll x=0,y=1;char c=getchar();
while (c<'0'||c>'9') {if (c=='-') y=-1;c=getchar();}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x*y;
}
ll get_num() {
ll res;
if (q1.empty()) {
res = q2.front();
q2.pop();
return res;
}
else if (q2.empty()) {
res = q1.front();
q1.pop();
return res;
}
else if (q1.front() > q2.front()) {
res = q2.front();
q2.pop();
return res;
}
else {
res = q1.front();
q1.pop();
return res;
}
}
int main() {
n = rd();
for (ll i = 1; i <= n; i ++ ) {
ll tmp;
tmp = rd();
buc[tmp] ++ ;
}
for (ll i = 1; i <= M; i ++ ) {
while (buc[i] > 0) {
q1.push(i);
buc[i] -- ;
}
}
for (ll i = 1; i <= n - 1; i ++ ) {
ll x = get_num(), y = get_num();
ans += (x + y);
q2.push(x + y);
}
printf("%lld",ans);
return 0;
}