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[], ans; int main()
{
int n;
scanf("%d", &n);
ans = ;
for(int i = ; i <= n; i++){
scanf("%I64d", &arry[i]);
ans += arry[i];
}
sort(arry + , arry + + n);
for(int i = ; (ans & ) && i <= n; i++){
if(arry[i] & ) ans -= arry[i];
}
printf("%I64d\n", ans);
return ;
}
上一篇:Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks dp+矩阵加速


下一篇:Codeforces Round #341 (Div. 2)A