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. sql 多条件查询 拼接字符串 改成 普通查询格式

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROC [dbo].[usp_SRV_CheckServiceDemandOrder] ) = ...

  2. 《小C QQ空间转帖、分享工具》之QQ空间数据传递的g_tk算法(C#)

    原文地址:http://user.qzone.qq.com/419067339/2 public string GET_HTTP(string url, string referer_post, st ...

  3. 加入商品分类信息,考虑用户所处阶段的 图模型 推荐算法 Rws(random walk with stage)

    场景: 一个新妈妈给刚出生的宝宝买用品,随着宝宝的长大,不同的阶段需要不同的物品. 这个场景中涉及到考虑用户所处阶段,给用户推荐物品的问题. 如果使用用户协同过滤,则需要根据购买记录,找到与用户处于同 ...

  4. linux环境开发私房菜

    1,各种linux 平台GUI开发IDE环境 2,C/C++ 好的编译器 gcc/emcs;

  5. Android Studio的配置

    第一次使用Android Studio时你应该知道的一切配置 - 生命壹号 - 博客园http://www.cnblogs.com/smyhvae/p/4390905.html

  6. css 中的若干心得

    css布局中定位机制主要是普通的流,也就是说按照HTML文本的顺序在窗口上从上到下.从左到右去显示,遇见块级元素就换行显示.为了更进一步的控制,我可以使用相对定位.绝对定位.固定定位以及浮动. 相对定 ...

  7. 最近做OpenWrt的总结

    用到了哪些东西 需要在OpenWrt上开发一个客户端,用C语言写还比较方便,最开始在linux上跑,后面移植到路由器上,做成ipk.除了稍微修改了下Makefile,其他的什么都没改. 因为需要做个配 ...

  8. EC读书笔记系列之4:条款8 别让异常逃离析构函数

    条款8 别让异常逃离析构函数 记住: ★析构函数绝对不要吐出异常.若一个被析构函数调用的函数可能抛出异常,析构函数应该捕捉任何异常,然后吞下它们(不传播)或结束程序. ★若客户需对某个操作函数运行期间 ...

  9. 为什么析构函数要加visual?

    一般来说,有使用visual的类,其析构函数都需要加上visual,这是为什么呢? 因为使用多态时,一般都是由基类指针来使用派生类的,在删除这个派生类对象时也一样,由基类指针来调用, 可以想象,如果析 ...

  10. 如何在MyEclipse中部署struts2的环境

    总记不住一些部署struts2框架的细节,下面就做一个总结:其实很简单,只要几步:1.下载的strutsXXX(版本号)-zip文件中解压app目录中有一个struts2-blank.war文件,解压 ...