CodeForces621A Wet Shark and Oddand Even

来源:互联网 发布:梁咏琪 知乎 编辑:程序博客网 时间:2024/05/17 02:45

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 100int 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);elseprintf("%lld\n",ans-min);}return 0;}/*********************************测试数据*********************************Input31 2 3Output6Input5999999999 999999999 999999999 999999999 999999999Output3999999996**************************************************************************/



0 0
原创粉丝点击