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. SQL Server中UPDATE和DELETE语句结合INNER/LEFT/RIGHT/FULL JOIN的用法

    在SQL Server中,UPDATE和DELETE语句是可以结合INNER/LEFT/RIGHT/FULL JOIN来使用的. 我们首先在数据库中新建两张表: [T_A] CREATE TABLE ...

  2. UITableView 和 UITableViewController

    UITableView:显示有多行数据的一个列. 新建一个过程:Xcode -> File -> New -> Project...,然后选择iOS -> Applicatio ...

  3. Tomcat完美配置多个HOST主机,域名,SSL

    这里是Tomcat9版本,其它版本基本一致! 1.配置多个主机域名 1.打开conf文件夹下的server.xml 复制官方提供的HOST配置,修改为你的域名,appBase路径(相对路径) 2.新建 ...

  4. 深入理解Redis高可用方案-Sentinel

    Redis Sentinel是Redis的高可用方案.是Redis 2.8中正式引入的. 在之前的主从复制方案中,如果主节点出现问题,需要手动将一个从节点升级为主节点,然后将其它从节点指向新的主节点, ...

  5. [书籍]用UWP复习《C#并发编程经典实例》

    1. 简介 C#并发编程经典实例 是一本关于使用C#进行并发编程的入门参考书,使用"问题-解决方案-讨论"的模式讲解了以下这些概念: 面向异步编程的async和await 使用TP ...

  6. pycharm 常用快捷键操作

    #最重要的快捷键 1. ctrl+shift+A:万能命令行 2. shift两次:查看资源文件 #新建工程第一步操作 1. module设置把空包分层去掉,compact empty middle ...

  7. 最小的N个和(堆)

    描述: 有两个长度为N的序列 AB,从AB中各选一个数,可以得到N^2个和,求这N^2个和中最小的N个 输入 5 1 3 2 4 5 6 3 4 1 7 输出 2 3 4 4 5 分析: 首先限定输出 ...

  8. 006-筛选分类排序搜索查找Filter-Classificatio-Sort-Search-Find-Seek-Locate

    006-筛选分类排序搜索查找Filter-Classificatio-Sort-Search-Find-Seek-Locate https://www.cnblogs.com/delphixx/p/1 ...

  9. 用python表白了!!!

    用python 画一颗心,代码:   import numpy as np import matplotlib.pyplot as plt x = np.linspace(-8 , 8, 1024) ...

  10. Auzre系列1.1.1 —— 安装用于 IntelliJ 的 Azure 工具包

    (文中大部分内容(95%)Azure官网上有,我只是把我自己实际操作中遇到的问题在这里阐述一下.) 先决条件 若要完成文章中的步骤,需要安装用于 IntelliJ 的 Azure 工具包,该工具包需要 ...