Sicily 2403. Voting

Time Limit: 1 secs, Memory Limit: 256 MB

Description

A committee clerk is good at recording votes, but not so good at counting and figuring the outcome correctly. As a roll call vote proceeds, the clerk records votes as a sequence of letters, with one letter for every member of the committee:

Y means a yes vote
N means a no vote
P means present, but choosing not to vote
A indicates a member who was absent from the meeting

Your job is to take this recorded list of votes and determine the outcome.
Rules:
There must be a quorum. If at least half of the members were absent, respond “need quorum”. Otherwise votes are counted. If there are more yes than no votes, respond “yes”. If there are more no than yes votes, respond “no”. If there are the same number of yes and no votes, respond “tie”.
Input

The input contains of a series of votes, one per line, followed by a single line with the # character. Each vote consists entirely of the uppercase letters discussed above. Each vote will contain at least two letters and no more than 70 letters.

Output

For each vote, the output is one line with the correct choice “need quorum”, “yes”, “no” or “tie”.

Sample Input

YNNAPYYNY
YAYAYAYA
PYPPNNYA
YNNAA
NYAAA
#
Sample Output

yes
need quorum
tie
no
need quorum
Problem Source

//每周一赛第四场


^_^ Just do it!

#include <iostream>
#include <map>

using namespace std;

int main()
{
    string str;
    map<char, int> mp;
    while (cin >> str && str != "#")
    {
        mp.clear();
        for (int i = 0; i < str.size(); i++){
            mp[str[i]]++;
        }
        if (mp['A'] * 2 >= str.size())
            cout << "need quorum" << endl;
        else if (mp['Y'] > mp['N'])
            cout << "yes" << endl;
        else if (mp['Y'] < mp['N'])
            cout << "no" << endl;
        else
            cout << "tie" << endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值