ZZULIOJ----2618: ACM-ICPC亚洲区域赛ZZUL

简介: ZZULIOJ----2618: ACM-ICPC亚洲区域赛ZZUL

题意描述:

玩了这么多游戏,V决定还是去做几道ACM题练练手,于是翻到了一道201X年ACM/ICPC亚洲区域赛某站的现场赛签到试题,但是由于多年不刷题,已经忘了怎么做了

作为将来的ACM校队扛把子的你,请帮助他解决一下吧。

现场赛题目如下:

Jenny likes balls. He has some balls and he wants to arrange them in a row on the table.

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?

hint:对于志在区域赛的acmer们,数学思维和英语读题能力是必不可少的 : )

hint again: 感谢husy(胡胜勇)对本次周赛试题的数据测试及标程提供

输入:

多实例

输入T,表示共有T组数据(T=100)

每组数据包含三个整数R,Y,B (0<= R,Y,B <=10000)

输出:

对于每组输入,输出最高得分

样例输入:

3
2 2 2
3 3 3
4 4 4

样例输出:

15
33
51

解题思路:这个题就是一个模拟的过程,因为题上说总和分最大也就是每一次放球都要保证得分最大。

1、当只有一种颜色球的时候,最后得分每一次最高为2;

2、当只有两种颜色的球和其中一种颜色球只有一个时候,最后每一次得到的最高分为3;

3、当只有两种颜色的球的时候 ,最后每一次得分最高为4;

4、当其中两种颜色的球只有一个的时候,最后每次最高得分为4;

5、当一种颜色球为1个另一个颜色球为2的时候,最后每次最高得分为5;

6、当一种颜色球为1,其余都大于2的时候,最后每次得分最高为5;

7、当三种颜色球都大于2的时候,最后每次得分最高为6;

程序代码:

#include<stdio.h>
int main()
{
    int i,n,m,j,k,T;
    long long a,b,c,sum;
    scanf("%d",&T);
    while(T--)
    {
        sum=0;
        scanf("%lld%lld%lld",&a,&b,&c);
        n=a+b+c;
        if(n==0||n==1)
            sum=0;
        if(n>=2)
            sum+=1;
        if(n>=3)
            sum+=2;
        if((a==0&&b==0)||(a==0&&c==0)||(c==0&&b==0))
        {
          if(n>=4)
            sum+=2*(n-3);
        }
        else if((a==0&&b==1)||(a==0&&c==1)||(c==0&&b==1)||((c==0&&a==1)||(b==0&&a==1)||(b==0&&c==1)))
        {
            if(n>=3)
                sum+=3*(n-3);
        } 
        else if((a==0&&b>1)||(a==0&&c>1)||(c==0&&b>1)||((c==0&&a>1)||(b==0&&a>1)||(b==0&&c>1)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4*(n-4);
        }
        else if((a==1&&b==1)||(a==1&&c==1)||(c==1&&b==1)||((c==1&&a==1)||(b==1&&a==1)||(b==1&&c==1)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4*(n-4);
        }
        else if((a==1&&b==2)||(a==1&&c==2)||(c==1&&b==2)||((c==1&&a==2)||(b==1&&a==2)||(b==1&&c==2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5*(n-5);
        }
        else if((a==1&&b>2)||(a==1&&c>2)||(c==1&&b>2)||((c==1&&a>2)||(b==1&&a>2)||(b==1&&c>2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5*(n-5);
        }
        else if((a>=2&&b>=2&&c>=2)||(a>=2&&c>=2&&b>=2)||(a>=2&&c>=2&&b>=2)||((b>=2&&c>=2&&a>=2)||(c>=2&&b>=2&&a>=2)||(a>=2&&b>=2&&c>=2)))
        {
            if(n>=4)
                sum+=3;
            if(n>=5)
                sum+=4;
            if(n>=6)
                sum+=5;
            if(n>=7)
                sum+=6*(n-6);
        }
        printf("%lld\n",sum);
    }
    return 0;
} 
相关文章
|
3天前
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
14 0
(2021 ICPC)亚洲区域赛(昆明)I.Mr. Main and Windmills
|
9月前
2022天梯赛三月冲刺——PAT (Advanced Level)1013 Battle Over Cities (并查集找连通块)
2022天梯赛三月冲刺——PAT (Advanced Level)1013 Battle Over Cities (并查集找连通块)
54 0
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
72 0
upc2021秋组队训练赛第一场 ICPC North Central NA Contest 2020
2020ICPC昆明站——J.Mr. Main and Windmills(计算几何)
2020ICPC昆明站——J.Mr. Main and Windmills(计算几何)
104 0
2020ICPC昆明站——J.Mr. Main and Windmills(计算几何)
|
边缘计算 Cloud Native 5G
OpenInfra Days China 2022 分论坛议程全览
OpenInfra Days China 2022 分论坛议程全览
118 0
OpenInfra Days China 2022 分论坛议程全览
|
边缘计算 Cloud Native 5G
OpenInfra Days China 2022 自由版块议程全览
OpenInfra Days China 2022 自由版块议程全览
101 0
OpenInfra Days China 2022 自由版块议程全览
|
Python
ZZULIOJ-1019,公园门票(Python)
ZZULIOJ-1019,公园门票(Python)
nowcoder-第三届湖北省赛-Mr.Maxwell and attractions (贪心)
一道比较细节的贪心题 题意: 一个人可以选择在上午上班或者是在下午上班,不上班的时间可以摸鱼游玩 有n个室内的风景,m个室外的风景,这n+m个风景有一个漂亮值 对于这n+m个风景,如果第一次观看漂亮值转换为开心值比率为100%,如果重复观看,每重复一次就会变成之前的60% 对于室外的风景,下午观看会降到80%,上午观看不影响,如果在下午重复观看室外的风景,获得的开心值就是preVal * 80% * 60 %。(效果加成作用) 问这个人至少在白天工作k天( >= k),总共n天,最大能获得多少开心值
83 0
nowcoder-第三届湖北省赛-Mr.Maxwell and attractions (贪心)
ZZULIOJ-1019,公园门票(Java)
ZZULIOJ-1019,公园门票(Java)