A.Sweet Problem

Title: Sweet problems

Meaning of the questions: Do you have three piles of candy: red, green, blue
on a pile of candy there are r, g a second reactor with candy, a third reactor with b candy
can be eaten in two different colors of candy every day, to find out the maximum number of days you can eat candy

Analysis: first row of lower order, if other than or equal to the maximum heap piles and then answer another and two stacks, and if smaller than the other two stacks, first to eliminate the maximum stack can, additionally assessed piles to eliminate out candy,
followed by even eliminate the remaining two piles each other, because to try to get the maximum number of days, so you want to share into two piles same two piles.

#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;
int a[3];
int t;
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> a[0] >> a[1] >> a[2];

        sort(a, a + 3);


        if (a[2] >= a[0] + a[1])
            printf("%d\n", a[0] + a[1]);
        else
        {
            //a[2] < a[0] + a[1]

            int res = 0;
            res += a[2];

            int t = (a[0] + a[1] - a[2]) / 2;
            res += t;
            printf("%d\n", res);
        }

    }


    return 0;
}

Guess you like

Origin www.cnblogs.com/pixel-Teee/p/11964094.html