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 ...
随机推荐
- Centos7安装Jenkins和目录迁移
Centos7安装Jenkins和目录迁移 内容: 安装Jenkins和相关的配置 尝试目录迁移,模拟磁盘空间不足 1. 安装Jenkins和配置 安装 根据Jenkins的官方安装指引,安装步骤如下 ...
- 【Shell】使用awk sed获取一行内容的两个值
突然有需求需要一个脚本,同时获取到每一行数据的两个值,下面做了一个例子模板,仅供记录参考 cat test.txt id=1,name=zclinux1 id=2,name=zclinux2 id= ...
- SAP中使用FTP服务
SAP中简单的FTP技术实现基本上如下几个步骤: 1.SM59建立FTP的RFC destination. 可以通过执行SAP的标准程序RSFTP005,自动创建两个名为SAPFTP何SAPFTPA的 ...
- Ice系列--强大如我IceGrid
前言 IceGrid是一个提供服务定位和服务激活的组件,但它的功能远不止于此.从它的命名可以看出它的设计理念-网格计算(grid computing).网格计算被定义为由一系列关联的廉价计算机组成的计 ...
- JAVA获取当前文件路径this.getClass().getResource方法详细讲解
public class Test { public void run() { // TODO Auto-generated method stub System.out.println(" ...
- 彻底解决小程序无法触发SESSION问题
一.首先找到第一次发起网络请求的地址,将服务器返回set-cookie当全局变量存储起来 wx.request({ ...... success: function(res) { console.lo ...
- 3.kafka安装配置
kafka安装配置 ### 1.集群规划 hadoop102 hadoop103 hadoop104 zk zk zk kafka kafka kafka jar包下载 http://kafka.ap ...
- scala/java等其他语言从CSV文件中读取数据,使用逗号','分割可能会出现的问题
众所周知,csv文件默认以逗号","分割数据,那么在scala命令行里查询的数据: 可以看见,字段里就包含了逗号",",那接下来切割的时候,这本应该作为一个整体 ...
- 【实战】ZooKeeper 实战
1. 前言 这篇文章简单给演示一下 ZooKeeper 常见命令的使用以及 ZooKeeper Java客户端 Curator 的基本使用.介绍到的内容都是最基本的操作,能满足日常工作的基本需要. 如 ...
- 洛谷P6218
感觉此题是P4317 花神的数论题的变形版 Description 求一段区间内二进制中 \(0\) 的个数不小于 \(1\) 的个数的数的个数 Solution 数位 DP 先考虑状态转移方程式,如 ...