Fortune Telling 数花瓣--算命

Time Limit: 2000MS Memory Limit: 262144K 64bit IO Format: %I64d& %I64u

[Submit [GoBack  [Status]

Description

Marina loves Sasha. But she keeps wondering whether Sasha lovesher. Of course, the best way to know it is fortune telling. Thereare many ways of telling fortune, but Marina has picked the easiestone. She takes in her hand one or several camomiles and tears offthe petals one by one. After each petal she pronouncesalternatively "Loves" and "Doesn't love", at that Marina alwaysstarts with "Loves". There are n camomilesgrowing in the field, possessing the numbers of petals equalto a1, a2, ... an. Marina wants to pick a bouquetwith the maximal possible total number of petals so that the resultwould still be "Loves". Help her do that; find the maximal numberof 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 secondline contains n integers ai (1 ≤ ai ≤ 100) which represent thenumber of petals on a given i-th camomile.

Output

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

Sample Input

Input
1

1

Output
1

Input
1

2

Output
0

Input
3

5 6 7

Output
13


#include<iostream>
using namespace std;
int main()
{
int n,i,sum,sum1,sum2,min,count;
int a[105];
while(scanf("%d",&n)!=EOF)
{   count=0;
min=INT_MAX;
sum=sum1=sum2=0;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
for(i=0;i<n;i++)
{
if((a[i])%2==0)  
{ sum1+=a[i];continue;}
            sum2+=a[i]; 
  count++;
      if(min>a[i]) 
    min=a[i];
 
}
if(count==0) { printf("0\n");continue;}

if(count%2!=0)
          printf("%d\n",sum1+sum2);
else 
printf("%d\n",sum1+sum2-min);
}

return 0;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值