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. Struts2命名空间问题

    警告: No configuration found for the specified action: '/myNameSpace/login.action' in names 今天花了点时间把st ...

  2. Oracle EBS-SQL (WIP-5):检查非标任务本身选上了MRP净值.sql

    SELECT WE.WIP_ENTITY_NAME,            MSI.SEGMENT1,            MSI.DESCRIPTION,            WDJ.CLASS ...

  3. STM32与LPC系列ARM资源之比较

    由于有周立公开发板的影响,LPC系列的开发板在工程师心目中一般是入门的最好型号之一.这次刚好有STM32的竞赛,正好将两者的资源进行比较一下(LPC系列以LPC213X为例). LPC213X包括LP ...

  4. SELinux开关导致mysql服务启动不了

    http://www.jb51.net/article/36187.htm 网站突然连接不上数据库,于是朋友直接重启了一下服务器.进到cli模式下,执行 service myqsld start 发现 ...

  5. sparse autoencoder

    1.autoencoder autoencoder的目标是通过学习函数,获得其隐藏层作为学习到的新特征. 从L1到L2的过程成为解构,从L2到L3的过程称为重构. 每一层的输出使用sigmoid方法, ...

  6. MFC_Office

    添加新项目,MFC应用程序 多个顶级文档,项目类型:Office,其他默认,点击下一步 复合文档支持:容器,右边都勾选,点击下一步 文件拓展名:c,全选,其他默认,点击下一步 数据库支持:无,其他默认 ...

  7. Pods 更新后提示Bundle资源找不到

    http://www.oschina.net/question/101347_2159145

  8. iOS 圆角那些事(转)

    似乎没有那家公司比Apple更爱圆角了,事实上,圆角也会让图形/产品看起来更加无侵略性,能够带来更好的用户体验.iOS开发中各种圆角也随处可见,最简单给控件添加圆角的方式就是给视图的layer设置co ...

  9. Linux--根文件系统的挂载过程分析

    前言: 本篇文章以S3C6410公版的Linux BSP和U-Boot来进行分析,文中全部提及的名词和数据都是以该环境为例,全部的代码流程也是以该环境为例来进行分析.哈哈.假设有不对或者不完好的地方, ...

  10. Java面试题之谈谈你对Struts的理解

    1. struts是一个按MVC模式设计的Web层框架,其实它就是一个大大的servlet,这个Servlet名为ActionServlet,或是ActionServlet的子类.我们可以在web.x ...