题解 | #数位dp?#
数位dp?
https://ac.nowcoder.com/acm/contest/66877/A
```#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int sum = 0;
int count = 0;
int n;
cin>>n;
int bag[n];
for(int i=0;i<n;i++){
cin>>bag[i];
}
sort(bag,&bag[n]);
for(int i=0;i<n;i++){ //取偶数并计算偶数个数
if(bag[i]%2==0){
sum +=bag[i];
count++;
}
}
int odd_count = n-count; //奇数个数
if(odd_count%2==0){
sum = 0;
for(int i=0;i<n;i++){
sum +=bag[i];
}
}
else{
for(int i=n-1;i>=0;i--){
if(bag[i]%2!=0&&odd_count>1){
sum +=bag[i];
odd_count--;
}
}
}
cout<<sum;
return 0;
}