浙江科技学院第十三届程序设计竞赛 1001:Let's go to play【细心】
2016-03-26 20:38
465 查看
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
AC-code:
#include<stdio.h> #include<cstring> using namespace std; int main() { int n,i,j,f[370],m[370],st,ed,max; char c; while(~scanf("%d",&n)) { memset(f,0,sizeof(f)); memset(m,0,sizeof(m)); for(i=0;i<n;i++) { getchar(); scanf("%c",&c); scanf("%d%d",&st,&ed); if(st>ed) j=st,st=ed,ed=j; if(c=='F') for(j=st;j<=ed;j++) f[j]++; else for(j=st;j<=ed;j++) m[j]++; } max=0; for(i=1;i<=366;i++) if(f[i]>max&&m[i]>max) max=f[i]>m[i]?m[i]:f[i]; printf("%d\n",2*max); } return 0; }
相关文章推荐
- Go语言学习(七)闭包和错误处理
- hdoj--Let's go to play(模拟)
- Let's go to play (模拟)
- Let's go to play
- Educational Codeforces Round 5 D. Longest k-Good Segment
- Go语言学习(六)函数
- hdu--Let's go to play
- Maltego卡在starting modules(或者卡在loading modules),无法进入程序(已解决)
- 杭电 Let's go to play
- mongo删除数据
- 避免使用import *
- 初识google多语言通信框架gRPC系列(一)概述
- Go语言学习(五)流程控制语句
- 【Algorithm】二分查找(递归实现)
- SGU414 Orthogonal Circles
- Go语言学习(四)常用类型介绍
- go语言defer执行时机简单分析
- 算法列表List of Algorithms
- 学习go语言的第6天(总结昨天)
- Django 学习资源