#include <cstdio>
#include <iostream>
#include <queue>
using namespace std;
void solve()
{
priority_queue<int> mypq;
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
mypq.push(x);
}
int ans = 0;
while (!mypq.empty())
{
int a = mypq.top();
mypq.pop();
if (!mypq.empty())
{
int b = mypq.top();
mypq.pop();
ans += b;
a -= b;
if (a != 0) mypq.push(a);
}else
{
ans += a;
}
}
printf("%d\n", ans);
}
int main()
{
// freopen("input.txt", "r", stdin);
int t;
scanf("%d", &t);
for (int i = 1; i <= t; i++)
{
cout << "Case #" << i << ": ";
solve();
}
}
07-19
07-19
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交