[Codeforces Round 273 (Div 2) C] [욕심 난 뇌 동] Table Decorations 3 종 풍선 장식 테이블 짝 꿍 3 개 풍선 완전 동 색 이 아 닌 최대 테이블 장식 수

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 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
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.
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=0,M=0,Z=1e9+7,ms63=1061109567;
LL a[5];
int main()
{
	for(int i=1;i<=3;++i)scanf("%lld",&a[i]);
	sort(a+1,a+4);
	gmin(a[3],(a[1]+a[2])*2);
	LL ans=(a[1]+a[2]+a[3])/3;
	printf("%lld
",ans); return 0; } /* 【trick&& 】 1, zjs , 。 2, , a[1] , wa , ! 3 AC 。 【 】 , a[1],a[2],a[3], [0,2e9] 。 , 。 , 。 【 】 【 】 ( ) , 。 , , 。 , , sum/3 , sum/3 ? , 。 , , a[1]<a[2]<a[3], a[3]=min(a[3],a[1]+a[2]<<1) sum/3 ~ */

좋은 웹페이지 즐겨찾기