Table Decorations
分类:思维、贪心
1.题意概述
- 给你三种颜色的气球Red、Green、Black和他们各自的个数,现在每张桌子要用三个气球装饰,要求同一张桌子的气球颜色不能完全相同,现在问你用这些气球能够最多装饰几张桌子?
2.解题思路
- 我们不关心具体方案,假设三种颜色气球数量从小到大分别是 a,b,c ,显然如果 c>2(a+b) ,剩下的c气球肯定用不着,因此我们实际上取 c ′=min{2(a+b),c} 即可,因为一张桌子用3个气球,我们贪心地选颜色不同的即可,因此答案就是 a+b+c ′3 !
3.AC代码
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 100010
#define lson root << 1
#define rson root << 1 | 1
#define lent (t[root].r - t[root].l + 1)
#define lenl (t[lson].r - t[lson].l + 1)
#define lenr (t[rson].r - t[rson].l + 1)
#define N 1111
#define eps 1e-6
#define pi acos(-1.0)
#define e exp(1.0)
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
ll a[3];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
long _begin_time = clock();
#endif
for (int i = 0; i < 3; i++)
scanf("%I64d", &a[i]);
sort(a, a + 3);
a[2] = min((a[1] + a[0] << 1), a[2]);
printf("%I64d\n", (a[0] + a[1] + a[2]) / 3);
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %ld ms.", _end_time - _begin_time);
#endif
return 0;
}