B. Ciel and Flowers
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Fox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:

  • To make a "red bouquet", it needs 3 red flowers.
  • To make a "green bouquet", it needs 3 green flowers.
  • To make a "blue bouquet", it needs 3 blue flowers.
  • To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower.

Help Fox Ciel to find the maximal number of bouquets she can make.

Input

The first line contains three integers rg and b (0 ≤ r, g, b ≤ 109) — the number of red, green and blue flowers.

Output

Print the maximal number of bouquets Fox Ciel can make.

Sample test(s)
input
3 6 9
output
6
input
4 4 4
output
4
input
0 0 0
output
0
Note

In test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.

In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.

题目意思是

做蓝的花束需要3朵蓝花,做红的花束需要3朵红花,绿的花束需要3朵绿花,混合花束需要3种颜色各一朵

现在给出红,绿,蓝花的数目,问最多有几个花束可以做出来。

贪心。对r,g,b分别除3取余数,为r1,g1,b1时,
然后排序一下,如果 r1==0 , g1 == 2, b1 == 2时,且原始的r答案再加1。减少一个r花的数目,换得2个混合花

/*
* @author ipqhjjybj
* @date 20130711
*
*/
#include <cstdio>
#include <cstdlib>
#include <algorithm>
void swap(int &a,int &b){
int t;
t=a,a=b,b=t;
}
int main(){
int r,g,b,ans=0;
scanf("%d %d %d",&r,&g,&b);
if(r==0||g==0||b==0){
printf("%d\n",r/3+b/3+g/3);
}else{
ans = r/3+g/3+b/3;
r%=3,g%=3,b%=3;
if(r>=g) swap(r,g);
if(r>=b) swap(r,b);
if(g>=b) swap(g,b);
// r<=g<=b
if(r==0&&g==2){
ans+=1;
}else{
ans+=r;
}
printf("%d\n",ans);
}
return 0;
}

CF 322B Ciel and Flowers 贪心水题的更多相关文章

  1. PAT甲题题解-1125. Chain the Ropes (25)-贪心水题

    贪心水题,每次取最短的两个绳子合并,长度缩减成一半 #include <iostream> #include <cstdio> #include <algorithm&g ...

  2. 【贪心算法】POJ-2393 简单贪心水题

    一.题目 Description The cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over ...

  3. UVA 11389 The Bus Driver Problem 贪心水题

    题目链接:UVA - 11389 题意描述:有n个司机,n个早班路线和n个晚班路线,给每个司机安排一个早班路线和一个晚班路线,使得每个早班路线和晚班路线只属于一个司机.如果一个司机早班和晚班总的驾驶时 ...

  4. cogs 1440. [NOIP2013]积木大赛 贪心水题

    1440. [NOIP2013]积木大赛 ★★   输入文件:BlockNOIP2013.in   输出文件:BlockNOIP2013.out   简单对比时间限制:1 s   内存限制:128 M ...

  5. UVa(11292),贪心水题

    蓝书P1, 很简单的一个贪心选择,用能力小的去砍小的.本来想双重循环,哎,傻逼了,直接遍历选手,碰到能砍的就砍掉. #include <stdio.h> #include <algo ...

  6. codeforces 672C - Recycling Bottles 贪心水题

    感觉很简单,就是讨论一下 #include <stdio.h> #include <string.h> #include <algorithm> #include ...

  7. 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing

    UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...

  8. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  9. hdu_2124 Flying to the Mars & hdu_1800 Repair the Wall 贪心水题

    hdu_1800 简单排一下序,从大开始把比他小的都访问一遍,ans++: #include <iostream> #include <stdio.h> #include &l ...

随机推荐

  1. android学习8(ListView高级使用)

    ListView在android更开放的,于是继续ListView说明使用. 首先创建一个android项目,项目名为ListViewTest. ListView的简单使用 改动布局文件,改动后代码例 ...

  2. 逗比学树莓派之GPIO

           wiringPi适合那些具有C语言基础,在接触树莓派之前已经接触过单片机或者嵌入式开发的人群.wiringPi的API函数和arduino很相似,这也使得它广受欢迎.作者给出了大量的说明 ...

  3. 华硕K55DR体验 - 显卡就是坑

    朋友拿来电脑,本来他室友已经把他电脑重做完了,但还是卡,非要给我再搞一遍,难道?我就是传说中的大神?咳咳...YY一下,适可而止 华硕K55DR的配置来看,似乎应付CF没什么问题,可是,FPS各种不稳 ...

  4. 编写Javascript类库(jQuery版

    编写Javascript类库(jQuery版) - 进阶者系列 - 学习者系列文章 Posted on 2014-11-13 09:29 lzhdim 阅读(653) 评论(1) 编辑 收藏 本系列文 ...

  5. 自制 Word、Excel 批转 PDF 工具

    原文:自制 Word.Excel 批转 PDF 工具 目前做金融业的项目,该公司每天会产生很多 Word.Excel 文档,需要大量地转换为 PDF,除了自己保存外,也要给金融主管机构作为备份.由于文 ...

  6. mediawiki在windows下的安装

    mediawiki在windows下的安装 对于刚接触wiki的朋友们来说,配置一个服务器环境,安装并运行mediawiki是一件很麻烦的事情,在这里,我尽量用通俗易懂的语言,介绍mw(mediawi ...

  7. cocos2d-x3.2中将XCode发展project转移到VS2010可能会发生错误

    一些代码在线xcode写.我们希望我们自己的屌丝vs上述的实施,要重新构建它project,然后加载.但是绝对 没想到在VS里新建project再加入文件,编译后出现了好多错误.以下就把解决这些错误的 ...

  8. css,js工具篇

    4. web前端开发分享-css,js工具篇   web前端开发乃及其它的相关开发,推荐sublime text, webstorm(jetbrains公司系列产品)这两个的原因在于,有个技术叫emm ...

  9. 《剑指Offer》面试题-用两个栈实现队列

    题目描述: 用两个栈来实现一个队列,完成队列的Push和Pop操作.队列中的元素为int类型. 输入: 每个输入文件包含一个测试样例.对于每个测试样例,第一行输入一个n(1<=n<=100 ...

  10. android中自定义Theme以及TitleBar

    1.自定义Theme. 在res/values/styles.xml中的resources块中添加如下代码: <style name="StatusBarBackground" ...