CodeForces 478C Table Decorations
2015-08-30 20:15
323 查看
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 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 Input
Input
Output
Input
Output
Input
Output
Hint
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.
View Code
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 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 Input
Input
5 4 3
Output
4
Input
1 1 1
Output
1
Input
2 3 3
Output
2
Hint
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 <string.h> #include <algorithm> using namespace std; int main() { long long r,g,b; long long a[10]; long long i,j,k; while(scanf("%I64d %I64d %I64d",&r,&g,&b)!=EOF) { long long s=0; a[1]=r,a[2]=g,a[3]=b; sort(a+1,a+4); s=s+a[1]; long long q=(a[2]+a[3])-a[1]*2,o; o=q/3; if(o<=a[2]) s=s+o; else s=s+a[2]; printf("%I64d\n",s); } return 0; }
View Code
相关文章推荐
- C语言基础知识之(十四):指针和字符数组、字符串数组
- CodeForces #318 (div1) B.Bear and Blocks
- Ubuntu 10.04 速配指南
- CodeForces 454C Little Pony and Expected Maximum
- Servlet3.1规范和JSP2.3规范
- Dataguard 重启方法
- Unity3D有限状态机(FSM)学习笔记【2】IState
- configure: error: in `/root/httpd-2.2.11/srclib/apr': c
- 找数
- uImage,zimage,bzimage,vmlinux,vmlinuz
- poj 3278 Catch That Cow(经典bfs)
- HDU 2476 String painter(区间DP啊)
- Jetty JNDI开发实战(上)
- 面试题11:数值的整数次方
- ES6的promise对象研究
- CodeForces 313C Ilya and Matrix
- 排序算法
- 蛋疼
- C语言基础知识之(十三):指针、指针和数组
- DUBBO简介及使用