cf-A. Wet Shark and Odd and Even(水)
2 seconds
256 megabytes
standard input
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.
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
题解:第一次打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(水)的更多相关文章
- 【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 ...
- Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even
题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include < ...
- codeforce 621A Wet Shark and Odd and Even
水 最大偶数和 #include<iostream> #include<string> #include<algorithm> #include<cstdli ...
- CodeForces 621A Wet Shark and Odd and Even
水题 #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #inclu ...
- cf 621E. Wet Shark and Blocks
神奇,矩阵乘法23333333333333333 递推式是很简单的(连我这种不会DP的人都写出来了.) 需要求出的是转移矩阵(还是叫系数矩阵的),也是最这个东西用快速幂. 这个东西的i,j大概就表示从 ...
- CodeForces--621A--Wet Shark and Odd and Even(数学水题)
Wet Shark and Odd and Even Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & ...
- 【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 ...
- Wet Shark and Flowers(思维)
C. Wet Shark and Flowers time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- B. Wet Shark and Bishops(思维)
B. Wet Shark and Bishops time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
随机推荐
- ERS卫星
http://www.esa.int/Our_Activities/Operations/ERS-2 ERS-2 ROLE Earth observation (EO) LAUNCH DATE 21 ...
- 在strings.xml中定义html标签
在项目的开发过程中,需要用到把html内容放到strings.xml文件中,然后再读取到TextView中.原本以为像普通文本一样直接SetText就行了,结果行不通,大大超出我的预料.经过网上搜索, ...
- C语言入门(19)——C语言的编码风格
代码风格好不好就像字写得好不好看一样,如果一个公司招聘秘书,肯定不要字写得难看的,同理,代码风格糟糕的程序员肯定也是不称职的.虽然编译器不会挑剔难看的代码,照样能编译通过,但是和你一个团队进行协作的其 ...
- Is life always hard?
原文来自我的独立blog: http://www.yuanyong.org/blog/midnightsun/is-life-always-hard 和两个朋友聊天. 小L在考研,打电话过去的时候小L ...
- Ubuntu12.04下eclipse提示框黑色背景色的修改方法
eclipse提示框的背景颜色使用的是系统的提示框颜色配置,在windows下为黄色,但在Ubuntu12.04(gnome)下却是黑色,造成提示内容很难看清. 在eclipse中我们是无法修改这个颜 ...
- Ajax框架,DWR介绍,应用,样例
使用Ajax框架 1. 简化JavaScript的开发难度 2. 解决浏览器的兼容性问题 3. 简化开发流程 经常使用Ajax框架 Prototype 一个纯粹的JavaScript函数库,对Ajax ...
- IIS Express中如何配置支持json
今天在使用i18next的时候,由于要加载一个json的文件,但是在vs2013中一直加载不成功呢,经过上网查资料得知原来要配置iis express才能支持json文件的加载. 文件的默认位置在:C ...
- 解决VS2010打开Web页面时经常由于内存较低而导致VS2010自动关闭的问题
在使用VS2010 开发Web应用程序的时候,经常打开一个Web页面进行编辑前台代码的时候要等待很久(甚至等了半天结果还挂掉,简直令人抓狂), 之前也在网上找了很多相关的方法,都没办法解决,今天无意中 ...
- zen-Coding的使用
zen-Coding的使用 zen-Coding的使用需要掌握CSS和HTML相关知识.其实只要对CSS的选择器比较熟悉,就可以得用简短的类似于CSS选择器的代码高效的编写出HTML代码.打开Note ...
- leetcode Trapping Rain Water pthon
class Solution(object): def trap(self,nums): leftmosthigh = [0 for i in range(len(nums))] leftmax=0 ...