好难啊
完全不会啊
| E | Compute's Collection |
这个检查点错误也不告诉错在哪好难顶啊
#include<cstdio>
#include<map>
using namespace std;
int main() {
int t;
scanf("%d", &t);
for (int o = 0; o < t; o++) {
int n;
scanf("%d", &n);
map<long long int,long long int> maps;
for (int i = 0; i < n; i++) {
int input;
scanf("%d",&input);
if (maps.find(input) == maps.end())
maps.insert({ input,1 });
else
maps[input]++;
}
map<long long int, long long int>::iterator last=maps.end();
for (map<long long int, long long int>::iterator itor = maps.begin(); itor != maps.end(); itor++) {
if (itor->second > 1) {
if (itor->second % 2 == 1) {
itor->second = 1;
continue;
}
else {
if (last != maps.end()) {
itor->second = 1;
last->second = 1;
last = maps.end();
}
else {
itor->second = 2;
last = itor;
}
}
}
}
long long int sum = 0;
for (auto i : maps)
sum += i.first;
if (last != maps.end())
sum -= maps.begin()->first;
printf("%lld\n", sum);
}
} 
