12674 - Eat candies
raw download clone
C
views 20
,
size 1331 b
#include <stdio.h>

int main(void)
{
    int t, i, r, g, b, x, y, z;

    scanf("%d", &t);
    for(i=1; i<=t; i++)
    {
        scanf("%d%d%d", &r, &g, &b);
        if(r >= g)
        {
            if(b >= r)
            {
                x = b;
                y = r;
                z = g;
            }
            else
            {
                if(b >= g)
                {
                    x = r;
                    y = b;
                    z = g;
                }
                else
                {
                    x = r;
                    y = g;
                    z = b;
                }
            }
        }
        else
        {
            if(b >= g)
            {
                x = b;
                y = g;
                z = r;
            }
            else
            {
                if(b >= r)
                {
                    x = g;
                    y = b;
                    z = r;
                }
                else
                {
                    x = g;
                    y = r;
                    z = b;
                }
            }
        }

        if(y + z <= x)
            printf("%d\n", y + z);
        else
            printf("%d\n", (x + y + z) / 2);
    }

    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.