Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

Posted

tags:

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

题意是得到最大的偶数和

解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数

#include <cstdio>
#include <cmath>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
#define INF 0x3f3f3f3f
#define mem(str,x) memset(str,(x),sizeof(str))  
#define STOP puts("Pause");
using namespace std;
typedef long long LL;

LL arry[100010], ans;

int main()
{
    int n;
    scanf("%d", &n);
    ans = 0;
    for(int i = 1; i <= n; i++){
        scanf("%I64d", &arry[i]);
        ans += arry[i];
    }
    sort(arry + 1, arry + 1 + n);
    for(int i = 1; (ans & 1) && i <= n; i++){
        if(arry[i] & 1) ans -= arry[i];
    }
    printf("%I64d\n", ans);
    return 0;
}

 

以上是关于Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #341 (Div. 2)

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

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

Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks(矩阵优化DP)

Codeforces Round #341 (Div. 2) C. Wet Shark and Flowers(简单容斥)