zzulioj - 2618: ACM-ICPC亚洲区域赛ZZULI站

题目链接;

http://acm.zzuli.edu.cn/problem.php?id=2618

题目描述
玩了这么多游戏,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)
输出
对于每组输入,输出最高得分
样例输入  Copy
3
2 2 2
3 3 3
4 4 4
样例输出  Copy
15
33
51

  这个题主要是考验细心和英语的读题能力,大概意思是你有三种颜色的球r,y,b个,每在一排球的末尾放一个球,加的分数相当于这个球前面球的种类数,
每在一排球的中间插入一个球,加的分数相当于这个球前面的球的种类数加上这个球后面球的种类数,显然,我们尽量往中间插入球的得到的收益是比
较高的,然后就是分析各种情况了,举个例子,比如有3种颜色的球且都大于2个,那么我们可以先放三个不同颜色的球,再放3个不同颜色的球,那我
们每在他们中间插入一个球,那么分数就会加6,其他情况类似就不多赘述了,直接看代码吧!

 
#include<set>
#include
#include
#include
#include
#include
#include
#include<string>
#include
#include
#include
#include
#include
#include
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define mst(a) memset(a, 0, sizeof(a))
#define _task printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double eps = 1e-7;
const int INF = 0x3f3f3f3f;
const ll ll_INF = 233333333333333;
const int maxn = 1e3+10;
int main(void) {
    int t;
    scanf("%d", &t);
    while(t--) {
        ll r, y, b;
        scanf("%lld%lld%lld", &r, &y, &b);
        ll temp = min(r, min(y, b));
        ll res;
        if (temp>=2)    //三种球都大于1
            res = 15 + (r+y+b-6)*6;
        else if (temp>=1) { 
            if ((r>1&&y>1) || (r>1&&b>1) || (y>1&&b>1)) //两种球大于1一种球小于1
                res = 10 + (r+y+b-5)*5;
            else if (r > 1 || y > 1 || b > 1) //两种球等于1一种球大于1
                res = 6 + (r+y+b-4)*4;
            else    //三种球都等于1
                res = 3;
        }
        else if ((!r && y>0 && b>0) || (!y && r>0 && b>0) || (!b && y>0 && r>0)) { 
            if ((r>1&&y>1) || (r>1&&b>1) || (y>1&&b>1)) //一种球等于0另外两种大于1
                res = 6 + (r+y+b-4)*4;
            else if (r > 1 || b > 1 || y > 1) //一种球等于0另外一种等于1一种大于1
                res = 3 + (y+r+b-3)*3;
            else    //一种球等于0,另外两种大于1
                res = 1;
        }
        else if (r>1 || y>1 || b>1) //只有一种球且大于1
            res = 1 + (y+r+b-2)*2;
        else // 只有一种球且等于1或者全都是0
            res = 0;
        printf("%lld\n", res);
    }
    return 0;
}

 

 

你可能感兴趣的:(zzulioj - 2618: ACM-ICPC亚洲区域赛ZZULI站)