Maison > interface Web > tutoriel HTML > Codeforces Round #273 (Div. 2) C Table Decorations_html/css_WEB-ITnose

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

WBOY
Libérer: 2016-06-24 11:56:08
original
1259 Les gens l'ont consulté

题目链接: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
Copier après la connexion

output

input

1 1 1
Copier après la connexion

output

input

2 3 3
Copier après la connexion

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 <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>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;}</time.h></stdlib.h></math.h></string></map></set></queue></vector></algorithm></iostream></string.h></stdio.h>
Copier après la connexion


source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal