博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C. Table Decorations(Codeforces Round 273)
阅读量:4571 次
发布时间:2019-06-08

本文共 1693 字,大约阅读时间需要 5 分钟。

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.

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.

首先要明确,当最大的气球数量的一半小于另外两种颜色的数量之和,肯定能够组成所有颜色数量之和/3,当最大的

气球数量的一半大于等于另外两种颜色的数量之和,所有组成为2+1,2为最多数量的颜色。

代码:

#include 
#include
#include
#include
using namespace std;int main(){ long long a[3]; scanf("%I64d%I64d%I64d",&a[0],&a[1],&a[2]); sort(a,a+3); long long ans=0; if((a[0]+a[1])<=a[2]/2) { ans=a[0]+a[1]; } else { ans=(a[0]+a[1]+a[2])/3; } printf("%I64d\n",ans); return 0;}

转载于:https://www.cnblogs.com/blfshiye/p/4085752.html

你可能感兴趣的文章
使用windows操作EXCEL如何关闭EXCEL进程
查看>>
转:KVC/KVO原理详解及编程指南
查看>>
redis 主从配置
查看>>
Centos 7.x 服务器部署常用命令
查看>>
Android开源实战:使用MVP+Retrofit开发一款文字阅读APP
查看>>
BZOJ4025 二分图 线段树分治、带权并查集
查看>>
[乐意黎原创] cuteftp 9 显示中文乱码
查看>>
操作MongoDB
查看>>
正则表达式 匹配中文 数字 字母 下划线
查看>>
TCP的状态迁移图
查看>>
统计连接到主机前十的ip地址和连接数
查看>>
第八周学习进度
查看>>
CopyUtils 讲一个对象的全部(或部分)属性值copy给另一个对象
查看>>
《局外人》豆瓣摘录
查看>>
数据库基础查询
查看>>
Eclipse安装SVN
查看>>
Linux性能优化建议
查看>>
OTL翻译(3) -- OTL的主要类
查看>>
java当中的定时器的4种使用方式
查看>>
hive
查看>>