【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 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.
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.
Print the maximum possible even sum that can be obtained if we use some of the given integers.
3
1 2 3
6
5
999999999 999999999 999999999 999999999 999999999
3999999996
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
题意
求n个数的子序列的和中最大偶数和。
分析
如果n个数总和为偶数,就直接输出,否则减去一个最小的奇数。
代码
#include<stdio.h>
long long n,a,minj=1e9+,sum;
int main(){
scanf("%I64d",&n);
for(int i=;i<n;i++)
{
scanf("%I64d",&a);
if(a% && a<minj) minj=a;
sum+=a;
}
if(sum%) sum-=minj;
printf("%I64d\n",sum);
return ;
}
【CodeForces 621A】Wet Shark and Odd and Even的更多相关文章
- 【38.24%】【codeforces 621E】 Wet Shark and Blocks
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【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 ...
- 【CodeForces 621B】Wet Shark and Bishops
题 题意 1000*1000的格子里,给你n≤200 000个点的坐标,求有多少对在一个对角线上. 分析 如果求每个点有几个共对角线的点,会超时. 考虑到对角线总共就主对角线1999条+副对角线199 ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- cf-A. Wet Shark and Odd and Even(水)
A. Wet Shark and Odd and Even time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 【codeforces 746E】Numbers Exchange
[题目链接]:http://codeforces.com/problemset/problem/746/E [题意] 你有n张卡片,上面写着不同的数字; 然后另外一个人有m张上面写着不同的数字的卡片: ...
- 【34.57%】【codeforces 557D】Vitaly and Cycle
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【39.29%】【codeforces 552E】Vanya and Brackets
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 604D】Moodular Arithmetic
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- git版本控制工具(二)----本地版本库的常用操作
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...
- 城堡 (spfa+cheng)
[问题描述] 给定一张?个点?条边的无向连通图,每条边有边权.我们需要从?条边中选出? − 1条, 构成一棵树. 记原图中从 1 号点到每个节点的最短路径长度为? ? ,树中从 1 号点到每个节点的最 ...
- 用uGUI开发自定义Toggle Slider控件
一.前言 写完<Unity4.6新UI系统初探>后,我模仿手机上的UI分别用uGui和NGUI做了一个仅用作演示的ToggleSlider,我认为这个小小的控件已能体现自定义控件的开发过程 ...
- QTP基础学习(一)安装目录介绍
上一篇介绍了QTP 10 安装,安装完成后就可以看到文件的目录了,这里主要介绍以下几个目录及作用. 简单介绍部分目录 1.addins:插件包 2.bin目录:可执行程序,这里存储了很多配置文件.运行 ...
- CPU相关知识-寄存器与存储器的区别
存储器一般在CPU外,一般指硬盘,U盘等可以在切断电源后保存资料的设备,容量一般比较大,缺点是读写速度都很慢,普通的机械硬盘读写速度一般是 50MB/S左右.内存和寄存器就是为了解决存储器读写速度慢而 ...
- java 20 - 8 字节流的文件复制以及汉字在计算机中的存储方式
复制文本文件:把当前目录下的FileIntputStream.java文件里面的内容复制到当前目录的b.txt文件中 分析: 数据源: FileIntputStream.java -- 读取数据 -- ...
- java 16 -7 泛型方法和泛型接口(泛型类相似)
写一个ObjectTool类 泛型方法:把泛型定义在方法上 格式 public <泛型类型> 返回类型 方法名(泛型类型) 这样的好处是: 这个泛型方法可以接收任意类型的数据 public ...
- Jsp页显示时间标签JSTL标签 <fmt:formatDate/> 实例大全
<fmt:formatDate value="${isoDate}" type="both"/>2004-5-31 23:59:59 <fmt ...
- 024医疗项目-模块二:药品目录的导入导出-HSSF导入类的学习
我们之前学习了怎么把数据的数据导出来保存到Excle中,这篇文章我们学习怎么Excel数据导出然后插入到数据库中. 我们先学习HSSF怎么用来导出数据. 看官方教程步骤如下: 第一步: 创建一个wor ...
- SQL 常见函数使用
1.字符串转化为整型 CONVERT(INT,'字符串') 2.结果集 输出为一段字符串 SELECT STUFF((SELECT ','+A FROM tableFOR XML PATH('')), ...