CodeForces 59BFortune Telling

来源:互联网 发布:python定义json字符串 编辑:程序博客网 时间:2024/04/30 05:33

Marina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her hand one or several camomiles and tears off the petals one by one. After each petal she pronounces alternatively "Loves" and "Doesn't love", at that Marina always starts with "Loves". There are n camomiles growing in the field, possessing the numbers of petals equal to a1, a2, ... an. Marina wants to pick a bouquet with the maximal possible total number of petals so that the result would still be "Loves". Help her do that; find the maximal number of petals possible in the bouquet.

Input

The first line contains an integer n (1 ≤ n ≤ 100), which is the number of flowers growing in the field. The second line contains n integers ai (1 ≤ ai ≤ 100) which represent the number of petals on a given i-th camomile.

Output

Print a single number which is the maximal number of petals in the bouquet, the fortune telling on which would result in "Loves". If there are no such bouquet, print 0 instead. The bouquet may consist of a single flower.

Example
Input
11
Output
1
Input
12
Output
0
Input
35 6 7
Output
13


先计算所有的和,然后再判断其是否为偶数,如果是奇数,减去个奇数就好


#include <iostream> #include <cstdio>#include <stdio.h>#include <cstdlib>#include <cmath>#include <algorithm>#include <climits>#include <cstring>#include <string>#include <set>#include <map>#include <queue>#include <stack>#include <vector>#include <list>#define rep(i,m,n) for(i=m;i<=n;i++)#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)const int inf_int = 2e9;const long long inf_ll = 2e18;#define inf_add 0x3f3f3f3f#define mod 1000000007#define vi vector<int>#define pb push_back#define mp make_pair#define fi first#define se second#define pi  3.1415927#define pii pair<int,int>#define Lson L, mid, rt<<1#define Rson mid+1, R, rt<<1|1const int maxn=5e2+10;using namespace std;typedef  long long ll;typedef  unsigned long long  ull; inline int read(){int ra,fh;char rx;rx=getchar(),ra=0,fh=1;while((rx<'0'||rx>'9')&&rx!='-')rx=getchar();if(rx=='-')fh=-1,rx=getchar();while(rx>='0'&&rx<='9')ra*=10,ra+=rx-48,rx=getchar();return ra*fh;}//#pragma comment(linker, "/STACK:102400000,102400000")ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}int n;int a[10000];int main(){ll sum =0;ios::sync_with_stdio(false);cin >> n;for(int i=0;i<n;i++){cin >> a[i];sum+=a[i];}sort(a,a+n);if(sum%2){cout<<sum<<endl;return 0;}else{int i=0;for(i=0;i<n;i++){if(a[i]%2){cout<<sum-a[i]<<endl;return 0;}}}cout<<0<<endl;return 0;}


0 0
原创粉丝点击