题解:P15055 [UOI 2023 II Stage] Gallery

· · 题解

题解:P15055 [UOI 2023 II Stage] Gallery

思路

显然,应该选择高度第一大和第二大的花瓶,这样花瓶组合就是最高的。

不过因为只有 3 个数,可以用 a,b,c 的总和减去最小值,剩下的就是第一大和第二大的和了。

完整代码

#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a+b+c-min(a,min(b,c));
    return 0;
}