跳到正文

个人记录

a

xiaowen0324_约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年7月15日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a;
	int odd=0;
	int even=0;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a%2==1){
			odd++;
		}if(a%2==0){
			even++;
		}
	}
	while(odd>even){
		odd-=2;
		even++;
	}
	if(even>odd){
		cout<<odd*2+1;
	}else{
		cout<<even+odd;
	}
	return 0;
}
原文