Table Decorations

CodeForces - 478C

你有r个红的,g个绿的和b个蓝的气球。要为宴会布置一张桌子,你恰好需要三个气球。附在桌子上的三个气球不应该有相同的颜色。如果我们知道每种颜色的气球的数量,最多可以装饰多少张桌子?

您的任务是编写一个程序,对于给定的值r、g和b,它将找到表的最大数量t,并且可以按照所需的方式进行装饰。

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.

Examples

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.

sol:搞了半天挂了无数次(菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜)被日爆了!!!

发现对于a,b,c在大部分情况下都可以凑到总个数不到三个为止(即(a+b+c/3))

注意我说的是大多数,来看一组数据 100000000 1 1

这个最多只有一种,这类情况就是a,b,c中最大的数比另外两个的和的两倍还大,这类的答案就是另外两个的和

Ps:代码短但是好难啊qaq

翻车现场↑

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
ll a,b,c;
int main()
{
ll Max;
R(a); R(b); R(c);
Max=max(max(a,b),c);
if(Max>*(a+b+c-Max)) Wl(a+b+c-Max);
else Wl((a+b+c)/);
return ;
}
/*
input
5 4 3
output
4 input
1 1 1
output
1 input
2 3 3
output
2 input
100 99 56
output
85
*/

codeforces478C的更多相关文章

随机推荐

  1. Apache Spark 内存管理详解(转载)

    Spark 作为一个基于内存的分布式计算引擎,其内存管理模块在整个系统中扮演着非常重要的角色.理解 Spark 内存管理的基本原理,有助于更好地开发 Spark 应用程序和进行性能调优.本文旨在梳理出 ...

  2. vim 正则非贪婪模式

    比如多匹配使用 .* 效果自然是贪婪模式,JS 的非贪婪很简单,是 .*? 即可,而 vim 不同,语法是 .\{-},注意 \ 转义.

  3. Charles 抓包工具安装和采坑记录

    Charles 抓包工具安装和采坑记录 网络抓包是解决网络问题的第一步,也是网络分析的基础.网络出现问题,第一步肯定是通过抓包工具进行路径分析,看哪一步出现异常.做网络爬虫,第一步就是通过抓包工具对目 ...

  4. 朱晔的互联网架构实践心得S1E10:数据的权衡和折腾【系列完】

    朱晔的互联网架构实践心得S1E10:数据的权衡和折腾[系列完] [下载本文PDF进行阅读] 本文站在数据的维度谈一下在架构设计中的一些方案对数据的权衡以及数据流转过程中的折腾这两个事情.最后进行系列文 ...

  5. H5 37-背景缩写

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Full Regularization Path for Sparse Principal Component Analysis

    目录 背景 Notation Sparse PCA Semidefinite Relaxation Low Rank Optimization Sorting and Thresholding 背景 ...

  7. Linux下查看文件系统磁盘使用

    [root@localhost ~]# df -h 可以查看所有文件系统的磁盘使用情况 du --max-depth=1 -h 可以查看当前目录下各子目录的磁盘使用情况 参考:http://www.2 ...

  8. MySQL查询优化注意下面的四个细节

    原文:http://bbs.landingbj.com/t-0-244231-1.html 在任何一个数据库中,查询优化都是不可避免的一个话题.对于数据库工程师来说,优化工作是最有挑战性的工作.MyS ...

  9. [转帖]Linux分页机制之分页机制的演变--Linux内存管理(七)

    Linux分页机制之分页机制的演变--Linux内存管理(七) 2016年09月01日 20:01:31 JeanCheng 阅读数:4543 https://blog.csdn.net/gatiem ...

  10. 用stringstream可以用来分割空格、tab、回车换行隔开的字符串:

    #include <iostream> #include <sstream> #include <vector> using namespace std; int ...