CodeForces 621A Wet Shark and Odd and Even

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CodeForces 621A Wet Shark and Odd and Even相关的知识,希望对你有一定的参考价值。

水题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<vector>
#include<algorithm>
using namespace std;

int n;
long long a[100000+10];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    sort(a,a+n);

    long long ans1=0,ans2=0,num=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0) ans1=ans1+a[i];
        else ans2=ans2+a[i],num++;
    }
    if(num%2==0) printf("%lld\n",ans1+ans2);
    else
    {
        for(int i=0;i<n;i++)
            if(a[i]%2==1)
                {ans2=ans2-a[i];break;}
        printf("%lld\n",ans1+ans2);
    }
    return 0;
}

 

以上是关于CodeForces 621A Wet Shark and Odd and Even的主要内容,如果未能解决你的问题,请参考以下文章

codeforces 621B Wet Shark and Bishops

codeforces 621C Wet Shark and Flowers

CodeForces 621B Wet Shark and Bishops

CodeForces 621C Wet Shark and Flowers

Codeforces Round #341 Div.2 B. Wet Shark and Bishops

Codeforces Round #341 Div.2 C. Wet Shark and Flowers