C-table Decorations
Time limit:1000ms Memory limit:262144kb 64bit IO format:%i64d &%i64u
Submit
Status
Practice
Codeforces 478C
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 has the same color. What maximum number t of tables can is decorated if we know number of balloons of each color?
Your task is to write a program this for given values R, G and B would find the maximum number t of tables, that can be Dec Orated 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 Respe Ctively. The numbers is separated by exactly one space.
Output
Print a single integer t-the maximum number of tables so 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
Idea: A[1],a[2],a[3] from small to large sort, if (a[1]+a[2]) *2<=a[3] Then the maximum is a[1]+a[2];
Otherwise: The maximum value is three and divisible by 3 (it can be thought that the decoration of each table is contributed by the maximum value of 2, the second big value contribution 1)
#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <algorithm>using namespace STD;typedef Long LongLl;ll a[5];intMain () { while(Cin>>a[1]>>a[2]>>a[3]) {ll sum=0; Sort (A +1, A +4);if((a[1]+a[2])*2<=a[3]) sum=a[1]+a[2];ElseSum= (a[1]+a[2]+a[3])/3;printf("%i64d\n", sum); }return 0;}
CF c-table Decorations