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 ...
随机推荐
- 克隆slave
在日常生活中,我们做的比较多的操作就是在线添加从库,比如线上有一主一丛两个数据库,由于业务的需要一台从库的读取量无法满足现在的需求,这样就需要我们在线添加从库,出于安全考虑,我们通常需要在从库上进行在 ...
- 【ORA】ORA-27101快速处理方法
今天朋友的数据库出了问题,报错如下: 这个问题主要是是spfile和pfile文件不一致导致的, 生成一个pfile,完了用pfile启动数据库即可 SQL> create pfile '/ho ...
- oracle动态采样导致数据库出现大量cursor pin s wait on x等待
生产库中,突然出现了大量的cursor pin s wait on x等待,第一反应是数据库出现了硬解析,查看最近的DDL语句,没有发现DDL.那么有可能这个sql是第一次进入 在OLTP高并发下产生 ...
- 你这样用过DO循环吗?
DATA: BEGIN OF text, word1(4) TYPE c VALUE 'This', word2(4) TYPE c VALUE 'is', ...
- uni-app开发经验分享十七: 开发微信公众号(H5)JSSDK 的使用方式
因为这个jssdk被uni-app坑了好多天,作者说支持1.4版本,但是我用1.4的两个分享的新方法一直不支持. 最后只能放弃了,期待什么时候能更新上. 基本的使用方法:第一步 - 下载使用方式下载地 ...
- 通过电脑浏览器调试真机h5兼容问题
前言 在h5开发过程中,起初我们使用PC浏览器的手机模式打开开发中的页面,并使用控制台进行调试,但实际真机兼容性问题无法调试到:在这种情况下,我们通常使用vConsole(即移动端的控制台)来调试,但 ...
- 前端面试准备笔记之JavaScript(03)
01. 变量声明提升 在预解析的时候,成员变量和函数,被提升到最高的位置,方便其他程序访问. 可以先使用后声明. 只提升变量名,不提升变量值 let const 声明的变量不具有变量声明提升. // ...
- [微信小程序]字体文件,字体图标(.ttf,.woff,woff2)等无法显示问题
一. 背景 项目引用了第三方UI框架Vant-weapp,但是前几天Vant的cdn被运营商封禁,导致van-icon无法使用. 有赞官方在Github上给出了在小程序app.wxss上添加以下代码的 ...
- JavaScript常用API
JavaScript常用API 节点属性 文档节点 事件监听.一出事件 获取元素方法
- 标准PE头属性说明