[CF478C] Table Decorations - 贪心

Description

为宴会装饰桌子,有 \(r\) 个红色,\(g\) 个绿色和 \(b\) 蓝色的气球,一张桌子需要三个颜色不全相同的气球来装饰。求出可以用所需方式进行装饰的桌子的最大数量 \(t\)

Solution

如果数量最大的数量的一半小于等于数量较小的两个之和,那么就可以全部拼掉

否则,全部按照 ABB 形式拼,数量为较小的两个之和

#include <bits/stdc++.h>
using namespace std;

#define int long long 
const int N = 100005;

signed main()
{
    ios::sync_with_stdio(false);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[2]>2*(a[0]+a[1])) cout<<(a[0]+a[1])<<endl;
    else cout<<(a[0]+a[1]+a[2])/3<<endl;
}

相关文章:

  • 2021-09-26
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
  • 2021-06-29
相关资源
相似解决方案