C. Table Decorations
1 second
256 megabytes
standard input
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.
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.
Print a single integer t — the maximum number of tables that can be decorated in the required manner.
5 4 3
4
1 1 1
1
2 3 3
2
这题一开始以为是模拟题,模拟了很久发现非常麻烦,后来看了代码,发现只要两个算式就行了。1、如果较小的两个数的和的两倍比第三个数小,那么直接输出这两个数的和,否则输出三个数的平均数。
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
__int64 a[10];
__int64 n,m,i,j;
while(scanf("%I64d%I64d%I64d",&a[0],&a[1],&a[2])!=EOF)
{
sort(a,a+3);
if((a[0]+a[1])*2<=a[2]){
printf("%I64d\n",a[0]+a[1]);continue;
}
else printf("%I64d\n",(a[1]+a[2]+a[0])/3);
}
return 0;
}
C. Table Decorations的更多相关文章
- CodeForces 478C Table Decorations
Table Decorations Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- cf478C Table Decorations
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- C. Table Decorations(Codeforces Round 273)
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 【CODEFORCES】 C. Table Decorations
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- codeforces 的 Codeforces Round #273 (Div. 2) --C Table Decorations
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #273 (Div. 2)-C. Table Decorations
http://codeforces.com/contest/478/problem/C C. Table Decorations time limit per test 1 second memory ...
- 贪心 Codeforces Round #273 (Div. 2) C. Table Decorations
题目传送门 /* 贪心:排序后,当a[3] > 2 * (a[1] + a[2]), 可以最多的2个,其他的都是1个,ggr,ggb, ggr... ans = a[1] + a[2]; 或先2 ...
- Codeforces Round #273 (Div. 2)C. Table Decorations 数学
C. Table Decorations You have r red, g green and b blue balloons. To decorate a single table for t ...
- CF-478C Table Decorations (贪心)
Table Decorations Time limit per test: 1 second Memory limit per test: 256 megabytes Problem Descrip ...
随机推荐
- JDK1.7-HashMap原理
JDK1.7 HashMap 如何在源码上添加自己的注释 打开jdk下载位置 解压src文件夹,打开idea,ctrl+shift+alt+s打开项目配置 选择jdk版本1.7,然后点击Sourcep ...
- unixbench性能测试跑分工具
UnixBench是一个类unix系(Unix,BSD,Linux)统下的性能测试工具,一个开源工具,被广泛用与测试linux系统主机的性能 所谓跑分工具,不仅各项的测试有得分,最后跑完也会有一个综合 ...
- 【SpringBoot】Spring Boot 集成SwaggerAPI
Spring Boot 集成SwaggerAPI 文章目录 Spring Boot 集成SwaggerAPI Swagger 添加依赖 配置类 config 控制类 controller 接口测试 页 ...
- 【Oracle】增量备份和全库备份怎么恢复数据库
1差异增量实验示例 1.1差异增量备份 为了演示增量备份的效果,我们在执行一次0级别的备份后,对数据库进行一些改变. 再执行一次1级别的差异增量备份: 执行完1级别的备份后再次对数据库进行更改: 再执 ...
- postgresql中权限介绍
postgresql权限分为实例的权限,数据库的权限,模式的权限,对象的权限,表空间的权限 实例的权限:由pg_hba.conf文件控制,控制那些用户那些IP以哪种方式连接数据库 数据库的权限:是否允 ...
- Java流程控制与Scanner类的使用
Java流程控制与Scanner类的使用 Scanner类 Scanner类可以使程序接受键盘输入,实现人机交互 一个完整的Scanner的使用例子: //创建一个扫描器对象,用于接收键盘数据 Sca ...
- JavaScript——深入了解this
前言 我曾以为func()其实就是window.func() function func(){ console.log('this : ' + this); } func();//this : [ob ...
- Ansible自动化运维工具的使用
Ansible自动化运维工具的使用 host lnventory 管理主机 ip root账号密码 ssh端口 core mod ...
- DP 状态 DP 转移方程 动态规划解题思路
如何学好动态规划(2) 原创 Gene_Liu LeetCode力扣 今天 算法萌新如何学好动态规划(1) https://mp.weixin.qq.com/s/rhyUb7d8IL8UW1IosoE ...
- 理想的DevOp流程怎么做?看看Slack的代码部署实践 原创 Michael Deng 高可用架构 今天
理想的DevOp流程怎么做?看看Slack的代码部署实践 原创 Michael Deng 高可用架构 今天