CodeForces621A Wet Shark and Oddand Even

Wet Shark and Oddand Even

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Today,Wet Shark is given n integers.Using any of these integers no more than once, Wet Shark wants to get maximumpossible even (divisible by 2)sum. Please, calculate this value for Wet Shark.

Note,that if Wet Shark uses no integers from the n integers,the sum is an even integer 0.

Input

Thefirst line of the input contains one integer, n (1 ≤ n ≤ 100 000).The next line contains n spaceseparated integers given to Wet Shark. Each of these integers is in range from 1 to 109,inclusive.

Output

Printthe maximum possible even sum that can be obtained if we use some of the givenintegers.

Sample Input

Input

3
1 2 3

Output

6

Input

5
999999999 999999999 999999999 999999999 999999999

Output

3999999996

 

就是看一组数字组成的最大的偶数

思路:标记奇数的最小值,如果ans是奇数则减去该值


/*=============================AC情况===============================*/
/*题目网址: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=117765#problem/A  */
/*时间:2016年5月27日21:45:49 */
/*心得:  */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define G 100

int main() {
	int t,min,n;
	long long ans;
	while(scanf("%d",&t)!=EOF) {
		ans=0;
		min=-1;
		for(int j=1; j<=t; j++) {
			scanf("%d",&n);
			ans=ans+n;
			if(min==-1&&(n%2!=0))
				min=n;
			if(n<min&&(n%2!=0))
				min=n;
		}
		if(ans%2==0)
			printf("%lld\n",ans);
		else
			printf("%lld\n",ans-min);
	}
	return 0;
}

/*********************************测试数据*********************************

Input
3
1 2 3
Output
6
Input
5
999999999 999999999 999999999 999999999 999999999
Output
3999999996
**************************************************************************/



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值