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 ...
随机推荐
- QJ系列笔记
1.求int型数据在内存中存储时1的个数输入一个int型数据,计算出该int型数据在内存中存储时1的个数. #include<stdio.h> void main() { ; int yu ...
- android支付宝支付开发过程
原文:android支付宝支付开发过程 支付宝开发流程: 1.在支付宝申请一个账号并开通开发者功能和移动支付的功能. 支付宝地址:https://auth.alipay.com/login/index ...
- Android手机自带内部存储路径的获取 (转)
转自:http://my.oschina.net/liucundong/blog/288183 我有一台中兴的Android手机,型号是 ZTE U930HD,手机没有插入外置SD卡(也就是Micro ...
- ecshop的模板文件中如何判断用户是否登录
ecshop中对于smarty的运用和改造有很大的值得借鉴的地方,在dwt模板文件中可以直接判断用户是否登录,现在有规定,凡是只展示不销售的电商平台,一律不得展示商品价格,但可以在用户登录后显示. & ...
- 导航栏控制器和标签栏控制器(UINavigationController和UITabBarController)混用
很多时候,在UI设计方面同时需要使用导航控制器和标签栏控制器,这时,需要掌握如何设计结合使用这两种不同控制器.比如手机QQ,程序有三个标签 栏(分别为消息.联系人.动态),同时在选择某个联系人或者会话 ...
- ftp 解决不能上传问题
有人建议整个关掉SELinux并且重启,于是我去/etc/selinux/config里面把SELinux给disable了.重启之后,发现可以在/home/sam/test这个文件夹上传了!
- canvas阴影
shadowOffsetx 阴影X轴的移动 shadowOffsety 阴影的y轴移动 shadowColor 阴影颜色 shadowBlur 模糊范围 <!DOCTYPE html>&l ...
- Web-----》》》 一般处理程序 ashx
一般处理程序 后缀: 前台页面:.ashx 后台页面:.ashx.cs 打开方式:右键程序集--在浏览器中查看--输入url(如http://localhost:6560/firstAshx.ashx ...
- Android 支付宝接入时常见的问题
1.概述 首先说明下,Android支付宝接入用的是快捷支付,下载地址是https://b.alipay.com/order/techService.htm 支付宝移动接入地址https://b ...
- ES6笔记② 箭头函数
特性介绍 箭头函数是ES6新增的特性之一,它为JS这门语言提供了一种全新的书写函数的语法. //ES5 function fun(x,y){ return x+y; } console.log(fun ...