Cued In

7024: Cued In

时间限制: 1 Sec  内存限制: 128 MB
提交: 127  解决: 54
[提交] [状态] [讨论版] [命题人:admin]

题目描述

Snooker is a cue sport played by two players on a rectangular table. The players take turns to pot a series of balls of varying colours, where each colour represents a distinct point value for potting the ball.
A player may pot any ball on the table initially, however any subsequent shots must follow a pattern: if the previous ball was red, the next ball must be another colour; otherwise, if there are still red balls left, the next ball must be red.
Balls of any colour other than red are initially replaced on the table every time they are potted, and may be used again to score more points. The balls stop being replaced once all of the red balls have been potted.
The values of each coloured ball are:

Snooker players are respected universally for their prowess in mental arithmetic. One sweeping glance across the table is enough to tell an experienced contestant how much they could score.
For newer players, however, this is a challenge. Write a program to help calculate a score for a given list of balls remaining on the table.

 

 

输入

•one line containing the integers N (1 ≤ N ≤ 21), the number of balls remaining on the table.
•N further lines, each containing the colour of one of the balls on the table.
The list of balls will not be ordered in any way and will contain at most one of each of yellow, green, brown, blue, pink and black.

 

输出

Output the largest possible score the player can make.

 

样例输入

5
red
black
pink
red
red

 

样例输出

37

虽然这题氵,但是我还是考虑不全。。居然自动忽略了全是红球的时候最多是1

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[8];
char op[50];
int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0;i<n;i++)
    {
        scanf("%s",op);
        if(!strcmp("red",op))
            a[1]++;
        else if(!strcmp("yellow",op))
            a[2]++;
        else if(!strcmp("green",op))
            a[3]++;
        else if(!strcmp("brown",op))
            a[4]++;
        else if(!strcmp("blue",op))
            a[5]++;
        else if(!strcmp("pink",op))
            a[6]++;
        else if(!strcmp("black",op))
            a[7]++;
    }
    int ans = 0,c = 7;

    while(c>1)
    {
        while(a[c])
        {
            while(a[1])
                a[1]--,ans+=c+1;
            ans+=c;
            a[c]--;
        }
        c--;
    }
    if(a[1])
        ans = 1;
    printf("%d\n",ans);

    return 0;
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值