hdoj--Let's go to play(模拟)

Let's go to play

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 773   Accepted Submission(s) : 213
Font: Times New Roman | Verdana | Georgia
Font Size:  

Problem Description

Mr.Lin would like to hold a party and invite his friends to this party. He has n friends and each of them can come in a specific range of days of the year from ai to bi.
Mr.Lin wants to arrange a day, he can invite more friends. But he has a strange request that the number of male friends should equal to the number of femal friends.

Input

Multiple sets of test data.

The first line of each input contains a single integer n (1<=n<=5000 )

Then follow n lines. Each line starts with a capital letter 'F' for female and with a capital letter 'M' for male. Then follow two integers ai and bi (1<=ai,bi<=366), providing that the i-th friend can come to the party from day ai to day bi inclusive.

Output

Print the maximum number of people.

Sample Input

4
M 151 307
F 343 352
F 117 145
M 24 128
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200

Sample Output

2

4

某人想办party,n个人分不同的时段出现,输入中M跟F代表不一样的性别,求人数最多的时候人有多少,因为这个主人的原因,他只会请男女相同的

,人数最大的时候应该是一个偶数,注意,这个人不是要请某个男女数目相同的时刻,请的人是可控的,所以可以是男女人数不同的时候

#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 50500
int f[MAXN],m[MAXN];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        memset(f,0,sizeof(f));
        memset(m,0,sizeof(m));
        int a,b;
        int x,y;
        char op;
        for(int i=0;i<n;i++)
        {
            getchar();
            scanf("%c%d%d",&op,&x,&y);
            if(op=='M')
            {
                for(int j=x;j<=y;j++)
                m[j]++;
            }
            else
            {
                for(int j=x;j<=y;j++)
                f[j]++;
            }
        }
        int ans=0;
        for(int i=1;i<=366;i++)
        {
            int minn=min(f[i],m[i]);
            ans=max(ans,2*minn);
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值