Codeforces Round #273 (Div. 2)(C)贪心,思维

来源:互联网 发布:机器人编程 招聘plc 编辑:程序博客网 时间:2024/05/16 14:34


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.

Examples
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.



题意:你有,红绿蓝,三种颜色的气球,分别有R,G,B个,现在有桌子需要你装饰,装饰的规则是每个桌子装饰三个气球,三个气球的颜色不能完全相同,问最多可以装饰多少桌子?


题解:如果R,G,B大小相近,那么就直接输出平均数就可以了,那如果最大的那个数字很大呢?我们最多可以利用的个数就是MAX=min(MAX,(其他2个的颜色的和)*2),他最多可以与另2种颜色组合他们的和的2倍,剩余更多的无法利用,然后输出平均值就可以了



#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<iostream>#include<algorithm>#include<vector>#include<map>#include<set>#include<queue>#include<string>#include<bitset>#include<utility>#include<functional>#include<iomanip>#include<sstream>#include<ctime>#include<cassert>using namespace std;#define N int(1e5)#define inf int(0x3f3f3f3f)#define mod int(1e9+7)typedef long long LL;#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)#define lld "%I64d"#else#define lld "%lld"#endif#ifdef CDZSC#define debug(...) fprintf(stderr, __VA_ARGS__)#else#define debug(...) #endifpriority_queue<LL>q;int main(){#ifdef CDZSCfreopen("i.txt", "r", stdin);//freopen("o.txt","w",stdout);int _time_jc = clock();#endifLL a[10];while (~scanf("%lld",&a[0])){LL ans = 0;for (int i = 1; i <= 2; i++){scanf("%lld", &a[i]);}sort(a, a + 3);a[2] = min(a[2], (a[1] + a[0])<<1);printf("%lld\n", (a[0]+a[2]+a[1])/3);}#ifdef CDZSCdebug("time: %d\n", int(clock() - _time_jc));#endifreturn 0;}










0 0
原创粉丝点击