http://codeforces.com/contest/478/problem/C

C. 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 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 test(s)
input
5 4 3
output
4
input
1 1 1
output
1
input
2 3 3
output
2
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.

解题思路:贪心, 两个较小的两倍若比最大的那个小,这输出2个较小的和,否则输出3个的和的三分之一

1 #include <stdio.h>

 2 
 3 int main(){
 4     long long r, g, b, ma, mi, mid, sum;
 5     while(scanf("%I64d %I64d %I64d", &r, &g, &b) != EOF){
 6         ma = mi = mid = r;
 7         sum = r + g + b;
 8         ma = ma > g ? ma : g;
 9         ma = ma > b ? ma : b;
         mi = mi < g ? mi : g;
         mi = mi < b ? mi : b;
         mid = sum - ma - mi;
         if(ma >  * (mid + mi)){
             printf("%I64d\n", sum - ma);
         }
         else{
             printf("%I64d\n", sum / );
         }
     }
     return ;
 }

Codeforces Round #273 (Div. 2)-C. Table Decorations的更多相关文章

  1. 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations

    题目传送门 /* 贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr... ans = a[1] + a[2]; 或先2 ...

  2. codeforces 的 Codeforces Round #273 (Div. 2) --C Table Decorations

    C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #273 (Div. 2)C. Table Decorations 数学

    C. Table Decorations   You have r red, g green and b blue balloons. To decorate a single table for t ...

  4. Codeforces Round #273 (Div. 2)

    A. Initial Bet 题意:给出5个数,判断它们的和是否为5的倍数,注意和为0的情况 #include<iostream> #include<cstdio> #incl ...

  5. Codeforces Round #273 (Div. 2) A , B , C 水,数学,贪心

    A. Initial Bet time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. Codeforces Round #345 (Div. 1) C. Table Compression dp+并查集

    题目链接: http://codeforces.com/problemset/problem/650/C C. Table Compression time limit per test4 secon ...

  7. Codeforces Round #345 (Div. 2) E. Table Compression 并查集

    E. Table Compression 题目连接: http://www.codeforces.com/contest/651/problem/E Description Little Petya ...

  8. codeforces Codeforces Round #345 (Div. 1) C. Table Compression 排序+并查集

    C. Table Compression Little Petya is now fond of data compression algorithms. He has already studied ...

  9. Codeforces Round #144 (Div. 2) D table

    CodeForces - 233D 题目大意给你一个n*m 的矩阵,要求你进行涂色,保证每个n*n的矩阵内都有k个点被涂色. 问你一共有多少种涂色方案. n<=100 && m& ...

随机推荐

  1. SPOJ PHT【二分】+SPOJ INUM【最小/大值重复】

    BC 两道其实都是水 没有完整地想好直接就码出事情.wa了一次以后要找bug,找完要把思路理的非常清楚 SPOJ PHT[二分] #include<bits/stdc++.h> using ...

  2. HDU5122【水】

    题意: 有n个数,然后按照冒泡排序的手段,只能往后移,然后问你最小几轮可以实现1-n 思路: 后边有比他小的数的话就一定要到后面去 求一下有多少个 PS: 如果还可以往前移,那么我们可以求一个最大确定 ...

  3. bzoj 3158: 千钧一发【最小割】

    这个条件非常妙啊,奇数和奇数一定满足1,因为\( (2a+1)^2+(2b+1)^2=4a^2+4a+4b^2+4b+2=2(2(a^2+a+b^2+b)+1) \)里面这个一定不是平方数因为除二后是 ...

  4. Ionic start 创建项目报错

    Installing npm packages... Error with start undefined Error Initializing app: There was an error wit ...

  5. sed 删除指定行

    参考:http://blog.sina.com.cn/s/blog_4ba5b45e0102e7l2.html

  6. C# 常量与只读属性的区别

    public readonly string name ----这个name是个只读属性,不需要在定义时初始化值,而是可以在构造函数中完成初始化. public const int age =18   ...

  7. 关于css中父元素与子元素之间margin-top的问题

    之前在使用经常遇到下面的问题: html: <div class="top"> <div class="one">I'm the fir ...

  8. Lock简介

    digest synchronized已经提供了锁的功能,而且还是Java的内置特性,那为什么还要出现lock呢? 用一句话来讲就是——synchronized可以实现同步,但太死板了它的同步机制:l ...

  9. Java 多个if 和多个else if 的区别

    int a=1; if(a==1){System.out.println("1");} if(a==2){System.out.println("2");} i ...

  10. [BZOJ2982]combination Lucas定理

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2982 $C(N,M)\% P = C(N\% P,M\% P) * C(N/P,M/P)\ ...