hdu-4811 Ball
题目链接:
Ball
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2149 Accepted Submission(s): 897
Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, Jenny has R red balls, Y yellow balls and B blue balls. He may put these balls in any order on the table, one after another. Each time Jenny places a new ball on the table, he may insert it somewhere in the middle (or at one end) of the already-placed row of balls.
Additionally, each time Jenny places a ball on the table, he scores some points (possibly zero). The number of points is calculated as follows:
1.For the first ball being placed on the table, he scores 0 point.
2.If he places the ball at one end of the row, the number of points he scores equals to the number of different colors of the already-placed balls (i.e. expect the current one) on the table.
3.If he places the ball between two balls, the number of points he scores equals to the number of different colors of the balls before the currently placed ball, plus the number of different colors of the balls after the current one.
What's the maximal total number of points that Jenny can earn by placing the balls on the table?
Each test case contains only one line with 3 integers R, Y and B, separated by single spaces. All numbers in input are non-negative and won't exceed 109.
3 3 3
4 4 4
33
51
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
int n,m,k;
int main()
{
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
if(n>=2&&m>=2&&k>=2)
{
LL ans=n-2+m-2+k-2;
printf("%lld\n",ans*6+15);
}
else
{
int a[4];
a[0]=n,a[1]=m,a[2]=k;
sort(a,a+3);
int num=0;
for(int i=0;i<3;i++)if(a[i]==0)num++;
if(num==3)printf("0\n");
else if(num==2)
{
if(a[2]==1)printf("0\n");
else printf("%d\n",a[2]*2-3);
}
else if(num==1)
{
if(a[2]==1)printf("1\n");
else
{
if(a[1]==1)
{
if(a[2]==1)printf("1\n");
else
{
LL ans=a[2]-2;
printf("%lld\n",3*ans+3);
}
}
else
{
LL ans=a[1]-2+a[2]-2;
printf("%lld\n",ans*4+6);
}
}
}
else
{
if(a[2]==1)printf("3\n");
else
{
if(a[1]==1)
{
LL ans=a[2]-2;
printf("%lld\n",6+ans*4);
}
else
{
LL ans=a[1]-2+a[2]-2;
printf("%lld\n",5*ans+10);
}
}
}
}
} return 0;
}
hdu-4811 Ball的更多相关文章
- HDU 4811 Ball 贪心
题目链接: 题目 Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 问题描述 ...
- HDU 4811 Ball -2013 ICPC南京区域现场赛
题目链接 题意:三种颜色的球,现给定三种球的数目,每次取其中一个放到桌子上,排成一条线,每次放的位置任意,问得到的最大得分. 把一个球放在末尾得到的分数是它以前球的颜色种数 把一个球放在中间得到的分数 ...
- [思考] hdu 4811 Ball
意甲冠军: 有三种颜色的小珠,每种颜色的量R,Y,B 转球进入桌面成序,有多少种不同的颜色分别砍下的球在球门前+有多少身后球不同的颜色 问:最大的总比分值 思考: 球和后面的球先放好.剩下的就放中间了 ...
- HDU - 4811 - Ball (思维)
题意: 给出一定数量的三种颜色的球,计算如何摆放得到值最大(有一定顺序) 有三种摆放方法 1.如果放的是第一个(桌子上原来没有),数值不变 2.如果在末尾追加一个,那么增加前面不同颜色的个数的值 3. ...
- Ball HDU - 4811
Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of tho ...
- hdu 4811 数学 不难
http://acm.hdu.edu.cn/showproblem.php? pid=4811 由于看到ball[0]>=2 && ball[1]>=2 && ...
- HDU 5821 Ball (排序)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5821 有n个盒子,每个盒子最多装一个球. 现在进行m次操作,每次操作可以将l到r之间盒子的球任意交换. ...
- HDU 5821 Ball (贪心)
Ball 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...
- hdu 5821 Ball 贪心
Ball 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5821 Description ZZX has a sequence of boxes nu ...
- HDU 5821 Ball (贪心排序) -2016杭电多校联合第8场
题目:传送门. 题意:T组数据,每组给定一个n一个m,在给定两个长度为n的数组a和b,再给定m次操作,每次给定l和r,每次可以把[l,r]的数进行任意调换位置,问能否在转换后使得a数组变成b数组. 题 ...
随机推荐
- Linux Shell系列教程之(十二)Shell until循环
本文是Linux Shell系列教程的第(十二)篇,更多Linux Shell教程请看:Linux Shell系列教程 在上两篇文章Linux Shell系列教程之(十)Shell for循环和Lin ...
- 实现跨域请求jsonp方式
原理:http://madong.net.cn/index.php/2012/12/368/ 调用端: $.getJSON("http://192.168.220.85:8001/esb/a ...
- 移除NDK方法
以下内容由:于伟建 提供 删除.project中的以下字段基本都是有cdt关键字的位置 删除.cproject然后重启eclipse,clean,重新编译我这里还有错误,就手动删了gen 删除包含cd ...
- js和html5实现画板
html5新添了一个重要又强大的标签元素<canvas>,该标签真有彻底替换掉flash的尽头,现在很多网页游戏就是用<canvas>完成的,下面代码就是用该标签制作的一个画板 ...
- 维翔主机asp主机使用遇到的问题及解决方案总结
1.数据库配置 在这里,我们会发现,红色圈起来的部分"Webadmin"处点击之后会报错,这是因为,数据库管理工具没有进行域名解析,需要在域名购买商处添加一个域名解析,mssql, ...
- arcgis python 更新顺序号
i = 0def myFun(): global i i=i +1 return i myFun() ========================== accumulate( ) total = ...
- WebActivatorEx 注入时的使用
WebActivator类库提供了3种功能,允许分别在Application_Start初始化之前,之后以及ShutDown的时候,分别执行指定的代码,并且允许多次指定.示例如下: [assembly ...
- R语言学习笔记:简单的回归分析
fitbit <- read.csv("fitbit.csv") date cal step dist floor sit inactive walk run2 ...
- Sql server 2008 R2 配置管理工具服务显示远程过程调用失败:0x800706be
Sql server 2008 R2 配置管理工具服务显示远程过程调用失败:0x800706be 今天在其他电脑配置 SQl server 2008 R2,安装完成后,发现打开配置管理工具服务 : ...
- Java或Android开发中,去掉块注释格式化后每行出现的星号(*)的解决方案。(Eclipse)
找到子项,在 Window->Prefrences->Java->Code Style->Formatter,点击New新建 Active profile,然后在Comment ...