题解 | 灵异背包?

灵异背包?

https://www.nowcoder.com/practice/812bcedbbe244c9b86e459a244af5ddf

import sys
n=int(input())
gh=list(map(int,input().split()))
we=sum(gh)
#如果总和为奇数说明序列至少含有一个奇数,排下序找到最小的那个删掉即可
gh.sort(reverse=False)
if we%2!=0:
    for i in gh:
        if i%2==1:
            gh.remove(i)
            break
print(sum(gh))

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务