您的位置:首页 > 其它

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

2016-03-10 13:59 281 查看
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.

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(...)
#endif

priority_queue<LL>q;
int main()
{
#ifdef CDZSC
freopen("i.txt", "r", stdin);
//freopen("o.txt","w",stdout);
int _time_jc = clock();
#endif
LL 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 CDZSC
debug("time: %d\n", int(clock() - _time_jc));
#endif
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: