zoukankan      html  css  js  c++  java
  • CodeForces 478C Table Decorations

    Table Decorations
    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

    Description

    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 rg 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 rg 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 Input

    Input
    5 4 3
    Output
    4
    Input
    1 1 1
    Output
    1
    Input
    2 3 3
    Output
    2

    Hint

    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.

     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <algorithm>
     4 using namespace std;
     5 int main()
     6 {
     7     long long r,g,b;
     8     long long a[10];
     9     long long i,j,k;
    10     while(scanf("%I64d %I64d %I64d",&r,&g,&b)!=EOF)
    11     {
    12         long long s=0;
    13         a[1]=r,a[2]=g,a[3]=b;
    14         sort(a+1,a+4);
    15         s=s+a[1];
    16         long long q=(a[2]+a[3])-a[1]*2,o;
    17         o=q/3;
    18         if(o<=a[2])
    19             s=s+o;
    20         else
    21             s=s+a[2];
    22         printf("%I64d
    ",s);
    23     }
    24     return 0;
    25 }
    View Code
  • 相关阅读:
    【9018:2221】[伪模板]可持久化线段树
    【9018:2208】可持久化线段树2
    【9018:2207】可持久化线段树1
    【POJ2187】Beauty Contest
    2017/11/22模拟赛
    2017/11/3模拟赛
    [AtCoder 2702]Fountain Walk
    [AtCoder3856]Ice Rink Game
    20170910模拟赛
    20170906模拟赛
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771534.html
Copyright © 2011-2022 走看看