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. J2SE知识点摘记(三)

    1.         在java只允许单继承,而不允许多重继承,也就是说一个子类只能有一个父类.但在java中却允许多层继承. 2.         非内部Class只能被public或者defaul ...

  2. hdu - 1083 - Courses

    题意:有P门课程,N个学生,每门课程有一些学生选读,每个学生选读一些课程,问能否选出P个学生组成一个委员会,使得每个学生代言一门课程(他必需选读其代言的课程),每门课程都被一个学生代言(1 <= ...

  3. Redis事务和分布式锁

    Redis事务 Redis中的事务(transaction)是一组命令的集合.事务同命令一样都是Redis最小的执行单位,一个事务中的命令要么都执行,要么都不执行.Redis事务的实现需要用到 MUL ...

  4. STL 源代码剖析 算法 stl_algo.h -- random_shuffle

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie random_shuffle ------------------------------- ...

  5. 从汇编来看i++与++i

    故事背景,一个正在c语言的家伙,问我++i 和 i++的问题,我当时由于要去上课没给他说,正好今晚有空就測试了一下例如以下代码: 编译环境:VS2010  语言:C++ #include <io ...

  6. 【转载】HTML和XML的区别

    本文源地址 http://blog.163.com/txl129_2006@126/blog/static/1851087820103218453645/ 有改动. 什么是HTML HTML的全拼是H ...

  7. 修改SharePoint平台登录者显示名称

    protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //提升权限,拿系统服务帐号来执行此段代码 ...

  8. 看到当年自己学SQL Server 的笔记

    数据库 数据量DataBase,不同类型的数据应该放到不同的数据库中, .便于对各个数据类别进行个性管理 .避免命名冲突 .安全性更高; table(表):数据库中的关系指的就是表; 一张表就是一个类 ...

  9. TSQL 根据经纬度计算两点间的距离;返回米(m)

    -- ============================================= -- Author:Forrest -- Create date: 2013-07-16 -- Des ...

  10. SPRING中事务的配置

    采用这种配置策略,完全可以避免增量式配置,所有的事务代理由系统自动创建.容器中的目标bean自动消失,避免需要使用嵌套bean来保证目标bean不可被访问.这 种配置方式依赖于Spring提供的bea ...