A. Wet Shark and Odd and Even
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible 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

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

Output

Print the maximum possible even sum that can be obtained if we use some of the given integers.

Sample test(s)
input
3 1 2 3
output
6
input
5 999999999 999999999 999999999 999999999 999999999
output
3999999996
题解:第一次打cf,写了两道水题,剩下的就完全没思路啊。。。
这个题让找给的数中可以加到的最大可以被2整除的数;水;
代码:
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%I64d",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%I64d",x)
#define P_ printf(" ")
const int MAXN=1e5+100;
int m[MAXN];
int main(){
int n;
while(~SI(n)){
__int64 ans=0,temp,top=0;
for(int i=0;i<n;i++){
SL(temp);
if(temp&1)m[++top]=temp;
else ans+=temp;
}
sort(m+1,m+top+1);
int t=1;
if(top&1)t++;
for(int i=t;i<=top;i++)ans+=m[i];
printf("%I64d\n",ans);
}
return 0;
}

  

cf-A. Wet Shark and Odd and Even(水)的更多相关文章

  1. 【CodeForces 621A】Wet Shark and Odd and Even

    题 Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wan ...

  2. Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

    题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include < ...

  3. codeforce 621A Wet Shark and Odd and Even

    水 最大偶数和 #include<iostream> #include<string> #include<algorithm> #include<cstdli ...

  4. CodeForces 621A Wet Shark and Odd and Even

    水题 #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #inclu ...

  5. cf 621E. Wet Shark and Blocks

    神奇,矩阵乘法23333333333333333 递推式是很简单的(连我这种不会DP的人都写出来了.) 需要求出的是转移矩阵(还是叫系数矩阵的),也是最这个东西用快速幂. 这个东西的i,j大概就表示从 ...

  6. CodeForces--621A--Wet Shark and Odd and Even(数学水题)

    Wet Shark and Odd and Even Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & ...

  7. 【CodeForces 621C】Wet Shark and Flowers

    题 There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such tha ...

  8. Wet Shark and Flowers(思维)

    C. Wet Shark and Flowers time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  9. B. Wet Shark and Bishops(思维)

    B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

随机推荐

  1. QStringList不是简单重命名的便利类,而是提供了额外的函数,比如sort和join等等

    以前一直以为就是重命名而已,原来还不是.QT真伟大,方便到家了.该有的,全都有现成的.

  2. POJ——多项式的加法

    1:多项式加法 查看 提交 统计 提问 总时间限制:  1000ms  内存限制:  5000kB 描述 我们经常遇到两多项式相加的情况,在这里,我们就需要用程序来模拟实现把两个多项式相加到一起.首先 ...

  3. C#,json字符串转换成Json对象

    将JSON的请求参数转化为C#可序列化对象! JSON请求参数: "{\"id\":1,"name":"张三","dep ...

  4. 浅谈css盒模型

    在我们网页上的每一个元素,一个按钮,一段文本,一张图片等等,浏览器都将它们当做一个“盒子”看待,并把这样的盒子称为盒模型(box model).使用Chrome的右键>审查元素对某个网页上的元素 ...

  5. win下vm10+mac os 10.9安装遇到问题

    在windows 8下安装vm10.0.0+mac os 10.9遇到问题记录例如以下: 一.因为之前我装的vm9+mac os 10.7: 二.准备安装mac os 10.9,把vm9换成vm10: ...

  6. UVA 10163 Storage Keepers(dp + 背包)

    Problem C.Storage Keepers  Background Randy Company has N (1<=N<=100) storages. Company wants ...

  7. 使用Vitamio打造自己的Android万能播放器(2)—— 手势控制亮度、音量、缩放

    前言 本章继续完善播放相关播放器的核心功能,为后续扩展打好基础.   声明 欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯伯: http://ove ...

  8. csharp中DateTime总结

    Table of Contents 1 时间格式输出 2 求某天是星期几 3 字符串转换为DateTime 3.1 String->DateTime 的弹性做法 4 计算2个日期之间的天数差 5 ...

  9. getopt()函数

    在讨论这个函数之前我们先理解两个概念:选项及其参数 gcc -o program program.c 在上述命令中 -o 就是其选项 program就是参数. getopt(): 头文件: #incl ...

  10. Linux 环境变量和source命令 (转)

    可能是班门弄斧了,仅share给尚不知道的童鞋. 1.       问题的来源: 为什么我们编译Android代码时,需要输入:  source ./build/envsetup.sh  或者 . . ...