【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 ...
 
随机推荐
- codeforces 487C C. Prefix Product Sequence(构造+数论)
			
题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes in ...
 - java 10-4 Scanner方法
			
Scanner:用于接收键盘录入数据 常用的两个方法(int举例): public int nextInt():获取一个int类型的值 public String nextLine():获取一个St ...
 - Myeclipse+maven时Tomcat部署时maven的依赖文件不能部署到Tomcat上
			
解决办法:
 - PHP基础16:多维数组
			
<?php //1.PHP-两维数组 $cars=array ( array("Volvo",22,18), array("BMW",15,13), ar ...
 - JS实现点击跳转登陆邮箱
			
前言 注册的过程中往往需要填写邮箱,并登陆邮箱进行验证.利用JS可以实现针对不同的邮箱进行点击登录验证,以下为实现方案,很简单 代码 邮箱域名数据 1 2 3 4 5 6 7 8 9 10 11 ...
 - Linq To Entities 及其相关(进阶)
			
上篇我们讲解了Linq To Entities的一些基本操作,这篇我们主要是讲解一些比较高级的东西:存储过程查询,SQL语句查询以及表达式树. 存储过程 首先来讲解存储过程查询. //Query a ...
 - JS 之BOM
			
BOM的核心对象是window,表示浏览器的一个实例. 使用框架时,window.top对象指顶层框架,也就是浏览器窗口.window.parent对象指包含当前窗口的框架,也就是父框架.window ...
 - iOS新加速计事件(陀螺仪和加速计)
			
iOS新加速计事件 [iOS新加速计事件] 1.iOS5.0以前,可以使用UIAcceleration来监听加速计事件. 2.Bug iOS5.0以后,UIAccelerometerDelegate已 ...
 - 掌握GCD以及后台永久运行的代码 (使用GCD处理后台线程和UI线程的交互)
			
一个例子: 在iPhone上做一个下载网页的功能,就是:在iPhone上放一个按钮,单击按钮时,显示一个转动的圆圈,表示正在进行下载,下载完成后,将内容加载到界面上的一个文本控件上. 使用GCD前: ...
 - 利用link标签的disabed属性大面积的对其他标签元素的CSS样式进行替换操作
			
由于平时对元素样式的控制基本上只是3,4个,所以一般用Jquery的时候直接使用$(element).css();这个方法,或者使用$(element).addClass()方法完成样式操作.对于小范 ...