好难啊

完全不会啊
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);
	}
}


全部评论
你太菜了
点赞 回复
分享
发布于 2021-04-17 17:04
不用这么麻烦 这是道思维题 不过这题真是见鬼,数据范围跟假的一样,骗我开int,调试5次一直没过。
点赞 回复
分享
发布于 2021-04-17 21:16
阿里巴巴
校招火热招聘中
官网直投
https://paste.ubuntu.com/p/YMTJDVcjdb/   我的代码  能a
点赞 回复
分享
发布于 2021-04-17 21:17

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务