HDU Let's go to play
来源:互联网 发布:双色球霸主软件怎么样 编辑:程序博客网 时间:2024/04/26 17:30
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.
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.
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
4M 151 307F 343 352F 117 145M 24 1286M 128 130F 128 131F 131 140F 131 141M 131 200M 140 200
Sample Output
24
看到这道题一直想着怎么用贪心。。。。看到别人的题解后才恍然大悟,模拟一下就行了。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int f[50050],m[50050];int main(){int n,i,j,k,l;while(scanf("%d",&n)!=EOF){memset(f,0,sizeof(f));memset(m,0,sizeof(m));int x,y;char t;for(i=0;i<n;i++){getchar();scanf("%c%d%d",&t,&x,&y);if(t=='M'){ for(j=x;j<=y;j++) m[j]++;} else { for(j=x;j<=y;j++) f[j]++;}}int ans=0;for(i=1;i<=366;i++){int minn=min(m[i],f[i]);ans=max(2*minn,ans);}printf("%d\n",ans);}return 0; }
0 0
- hdu--Let's go to play
- HDU Let's go to play
- Let's go to play
- 杭电 Let's go to play
- Let's go to play (模拟)
- HDOJ Let's go to play
- Today is beautiful day,let's go to play~
- hdoj--Let's go to play(模拟)
- 浙江科技学院第十三届程序设计竞赛 1001:Let's go to play【细心】
- HDU 1824 Let's go home
- Let’s Play Games!
- let‘s play game!
- Let's GO GO GO
- hdu 1824 Let's go home(s-sat)
- 坚定不移,let's go--------
- 好玩,Let's Go.....
- OK,let's go!
- Let`s go
- oracle_触发器监控修改字段的客户端IP、用户名、新旧值
- mybatis中mapper类型的XML
- Build.gradle详细配置说明
- Numpy库进阶教程(一)求解线性方程组
- 使用SOCKET实现TCP/IP协议的通讯
- HDU Let's go to play
- 会话跟踪
- httpclient 4.5.1---高级主题
- 第69课:Spark SQL通过Hive数据源JOIN实战 每天晚上20:00YY频道现场授课频道68917580
- shiro入门8:Shiro前几章复习
- 深入理解JavaScript系列(二): 原型、原型链与继承
- RunLoop应用场景
- MFC-自定义消息
- JVM运行时数据区域