好难啊

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


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

相关推荐

07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-03 18:22
投了几百份简历,专业和方向完全对口,都已读不回。尝试改了一下学校,果然有奇效。
steelhead:这不是很正常嘛,BOSS好的是即便是你学院本可能都会和聊几句,牛客上学院本机会很少了
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务