浙江科技学院第十三届程序设计竞赛1001
2016-03-26 21:50
225 查看
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
<span style="font-family:KaiTi_GB2312;font-size:24px;">#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int f[370],m[370];
int main()
{
int n,a,b;
char s;
while(scanf("%d",&n)==1)
{
memset(f,0,sizeof(f));
memset(m,0,sizeof(m));
for(int i=0;i<n;i++)
{
getchar();
scanf("%c%d%d",&s,&a,&b);
if(a>b)
{
int t=a;
a=b;
b=a;
}
if(s=='F')
{
for(int j=a;j<=b;j++)
f[j]++;
}
else{
for(int j=a;j<=b;j++)
m[j]++;
}
}
int ans=0;
for(int i=1;i<=366;i++)
{
if(m[i]>ans&&f[i]>ans)
{
ans=m[i]>f[i]?f[i]:m[i];
}
}
printf("%d\n",ans*2);
}
return 0;
}</span>
相关文章推荐
- 14软件工程第四次作业
- 尝试VS插件
- activiti--完成当前任务,动态指定下一级执行者
- spring
- 那么远,那么近
- 数组中的最大差值
- BestCoder Round #77 (div.2)xiaoxin juju needs help
- FrameBuffer(LCD设备层编程)
- 配置nginx使之支持pathinfo
- 解决由于DNS解析导致Emacs启动巨慢的问题 推荐
- PAT (Advanced Level) Practise 1114 Family Property (25)
- 未能加载文件或程序集“MySQLDriverCS
- strcpy和strncat函数
- 有关软件工程的问题的分析和讨论及课后的作业2
- 页面定时刷新或自动跳转
- 浙江科技学院第十三届程序设计竞赛1008
- 在OSX上开发UNITY本地插件的经验分享
- IOS本地通知实现
- 与运算与异或运算的应用
- 如何建立自己的知识体系