【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 ...
随机推荐
- HDU 1892 See you~
最裸的二维树状数组,但是因为内存太大(c[1010][1010]),好像不能运行,结果蒙着写,写了好久.. 代码: #include <iostream> #include <cst ...
- Android UI组件----ListView列表控件详解
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- 第22章 DLL注入和API拦截(1)
22.1 注入的一个例子(跨进程子类化窗口) ①子类化窗口可以改变窗口的行为,让发往该窗口的消息重新发到我们指定的过程来处理.但这种行为只能在本进程中(如A),对于从一个进程(如B)去子类化另一个进程 ...
- C和指针笔记 3.6链接属性
链接属性决定如何处理在不同文件中出现的标识符.标识符的作用域也它的链接属性有关,但这两个属性并不相同. 没有链接属性的标识符(none)总是被当作单独的个体,也就是说该标识符的多个声明被当作独立不同的 ...
- 微软职位内部推荐-Software Engineer II
微软近期Open的职位: Job Description Group: Search Technology Center Asia (STCA)/Search Ads Title: SDEII-Sen ...
- 深入了解view以及自定义控件
参考文章: http://blog.csdn.net/guolin_blog/article/details/12921889 Android LayoutInflater原理分析,带你一步步深入了解 ...
- JQuery判断数组中是否包含某个元素$.inArray("js", arr);
var arr = [ "xml", "html", "css", "js" ]; $.inArray(" ...
- 如何清洗 Git Repo 代码仓库
git prune 如何清洗 Git Repo 代码仓库 在腾讯云上创建您的SQL Cluster>>> » 相信不少团队的代码仓库 Git Repo 变得越来越大. ...
- android软键盘的一些控制 转来的,格式有点乱
"EditText + Button" 形成一个 "输入+按键响应" 的案例在android编程中是最常见不过的了. 但还有一些细节需要注意: 在EditTe ...
- java之运算符
package com.simope.myTest; import java.util.HashMap; import java.util.Iterator; import java.util.Map ...