0
点赞
收藏
分享

微信扫一扫

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) : 771   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



//题意:



给你一个n,表示有n个人,接下来输入n行,每行第一个是一个字母,若为M,表示女生,接着一个s(起始天日期),一个e(结束的日期)。现在要求在某一天人数最多,并且男生人数和女生人数相同,问最多人数是多少。



直接模拟,然后再从1--366遍历就行了,不能对其排序,排完序后会超时(TML了2次)。



#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define INF 0x3f3f3f3f
#define ull unsigned long long
#define ll long long
#define IN __int64
#define N 380
#define M 1000000007
using namespace std;
struct zz
{
	int m;
	int f;
	int z;
}p[N];
int cmp(zz a,zz b)
{
	return a.z<b.z;
}
int main()
{
	int t,n,m;
	int i,j,k;
	char c[2];
	int s,e;
	while(scanf("%d",&n)!=EOF)
	{
		memset(p,0,sizeof(p));
		for(i=0;i<n;i++)
		{
			scanf("%s%d%d",c,&s,&e);
			for(j=s;j<=e;j++)
			{
				if(c[0]=='M')
					p[j].m++;
				else
					p[j].f++;
				p[j].z++;
			}
		}
		int mm=0,mi;
		for(i=1;i<=366;i++)
		{
			mi=min(p[i].m,p[i].f);
			if(mm<mi)
				mm=mi;
		}
		printf("%d\n",mm*2);
	}
	return 0;
}



举报

相关推荐

0 条评论