【Codeforces 629 B Far Relative’s Problem】
来源:互联网 发布:阳光下的罪恶 知乎 编辑:程序博客网 时间:2024/04/29 03:40
B. Far Relative’s Problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of course, Famil Door wants to have as many friends celebrating together with him as possible.
Far cars are as weird as Far Far Away citizens, so they can only carry two people of opposite gender, that is exactly one male and one female. However, Far is so far from here that no other transportation may be used to get to the party.
Famil Door should select some day of the year and invite some of his friends, such that they all are available at this moment and the number of male friends invited is equal to the number of female friends invited. Find the maximum number of friends that may present at the party.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ 5000) — then number of Famil Door’s friends.
Then follow n lines, that describe the friends. Each line starts with a capital letter ‘F’ for female friends and with a capital letter ‘M’ for male friends. 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 that may come to Famil Door’s party.
Examples
Input
4
M 151 307
F 343 352
F 117 145
M 24 128
Output
2
Input
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200
Output
4
Note
In the first sample, friends 3 and 4 can come on any day in range [117, 128].
In the second sample, friends with indices 3, 4, 5 and 6 can come on day 140.
~~~手速题~~
AC代码:
#include<cstdio>#include<algorithm>using namespace std;int M[380],F[380],N,a,b;char s[2];int main(){ while(scanf("%d",&N) != EOF){ fill(F,F + 370,0); fill(M,M + 370,0); while(N--){ scanf("%s %d %d",s,&a,&b); if(s[0] == 'M'){ for(int i = a; i <= b ;i++) M[i]++; } else{ for(int i = a; i <= b ;i++) F[i]++; } } int ans = 0; for(int i = 1 ; i <= 366 ; i++) ans = max(ans,min(F[i],M[i])); printf("%d\n",ans * 2); } return 0;}
- CodeForces 629B Far Relative’s Problem
- 【CodeForces】[629B]Far Relative’s Problem
- CodeForces-629B-Far Relative’s Problem
- 【Codeforces 629 B Far Relative’s Problem】
- Codeforces 629B Far Relative’s Problem(简单区间贪心)
- CodeForces NO.629B Far Relative’s Problem
- Codeforces 629B Far Relative’s Problem(简单区间贪心)
- CodeForces 629 B. Far Relative’s Problem(水~)
- Codeforces 629B Far Relative’s Problem 【水题】
- Codeforces--629B--Far Relative’s Problem(模拟)
- CodeForces 629B Far Relative’s Problem(暴力)
- Codeforces 629B Far Relative’s Problem【模拟】
- Codeforces 629B Far Relative’s Problem 区间贪心
- Codeforces 629B(贪心Far Relative’s Problem
- CodeForces - 629B Far Relative’s Problem (贪心
- codeforces 629-B. Far Relative’s Problem(思想)
- 【codeforces】Far Relative’s Problem
- 【codeforces】 Far Relative’s Problem
- 学习小记 - Python爬虫 (1) 静态网页糗事百科的爬取
- css 水平居中 margin:0 auto
- spring配置文件详解--真的蛮详细
- kanzi学习之路(序)
- 关于Javac命令和类文件之间的依赖问题
- 【Codeforces 629 B Far Relative’s Problem】
- Jetty学习四:部署到Jetty
- 主进程中GCD用main queue会卡死但新生成queue却没问题
- ${pageContext.request.contextPath} JSP取得绝对路径
- BZOJ 3505: [Cqoi2014]数三角形
- css3中的transition与animation中的delay问题
- c语言字符串总结
- Hibernate 配置文件中的方言
- web开发基础