B2094 不与最大数相同的数字之和 题解

· · 题解

本题解为 Python 题解,原题链接:B2094 不与最大数相同的数字之和

本题会有多个最大值。还是查找最大值使用 max(),查找最大值的个数使用 count(),最后要注意本题数据中有 n=0 的情况,使用 Python 时需要特判,代码如下:

n=int(input());
if n==0:
    print(0);
    exit();
a=input().split();
a=[int(x) for x in a];
print(sum(a)-max(a)*a.count(max(a)));