欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

Codeforces Round #273 (Div. 2) C Table Decorations_html/css_WEB-ITnose

程序员文章站 2022-04-13 08:17:52
...
题目链接:Table Decorations


Table Decorations

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color?

Your task is to write a program that for given values r, g and b will find the maximum number t of tables, that can be decorated in the required manner.

Input

The single line contains three integers r, g and b (0?≤?r,?g,?b?≤?2·109) ? the number of red, green and blue baloons respectively. The numbers are separated by exactly one space.

Output

Print a single integer t ? the maximum number of tables that can be decorated in the required manner.

Sample test(s)

input

5 4 3

output

input

1 1 1

output

input

2 3 3

output

Note

In the first sample you can decorate the tables with the following balloon sets: "rgg", "gbb", "brr", "rrg", where "r", "g" and "b" represent the red, green and blue balls, respectively.




解题思路:用三种颜色的气球装饰桌子,每个桌子装饰三个气球,并且规定每个桌子不能只用一种颜色的气球装饰,给出三种颜色气球的的个数,求最多可以装饰多少个桌子。

很显然,讨论一下,两种较少的气球的个数的和是否小于最多气球的个数的一半,若小于,则每个桌子用两个个数最多的气球,再加上另两种气球中的任一个即可;若不小于,则最大值为三种气球的总个数的平均数。




AC代码:

#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INF 0x7ffffffflong long a[4], t;int main(){    #ifdef sxk        freopen("in.txt","r",stdin);    #endif    int n;    while(scanf("%lld%lld%lld",&a[0], &a[1], &a[2])!=EOF)    {        sort(a, a+3);        if(a[2] > 2*(a[0]+a[1])) t = a[0] + a[1];        else        t = (a[0]+a[1]+a[2])/3;        printf("%lld\n", t);    }    return 0;}