博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #343 (Div. 2) B. Far Relative’s Problem 暴力
阅读量:6343 次
发布时间:2019-06-22

本文共 2019 字,大约阅读时间需要 6 分钟。

B. Far Relative’s Problem

题目连接:

Description

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.

Sample Input

4

M 151 307
F 343 352
F 117 145
M 24 128

Sample Output

2

Hint

题意

有n个人

M/F 表示这个人的性别,Li,Ri,表示这个人[Li,Ri]都可以来

你需要找到一天,男女成对的数量最多,问你这天成对的数量*2是多少

题解:

直接暴力,然后扫一遍就好了

代码

#include
using namespace std;const int maxn = 400;int a[2][maxn];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) { char s[3];int l,r; scanf("%s%d%d",s,&l,&r); if(s[0]=='M') { for(int j=l;j<=r;j++) a[0][j]++; } else { for(int j=l;j<=r;j++) a[1][j]++; } } int ans = 0; for(int i=0;i<=366;i++) ans=max(ans,2*min(a[0][i],a[1][i])); cout<
<

转载地址:http://vskla.baihongyu.com/

你可能感兴趣的文章
2款比较炫的图片左右切换,放大效果。
查看>>
nginx下日志切割的shell
查看>>
动态代理实例
查看>>
GNS3 配置Static p2p GRE over IPsec
查看>>
Linux下软件的安装与管理(四)
查看>>
Immutable集合
查看>>
百度竞价排名屏蔽插件for Chrome
查看>>
MySQL数据库水平切分的实现原理解析
查看>>
python网络编程学习笔记(7):HTML和XHTML解析(HTMLParser、BeautifulSoup)
查看>>
ctf.360.cn第二届,逆向部分writeup——第二题
查看>>
Windows Server 2012 将资源发布到 AD DS
查看>>
Redhat linux C 函数 以及一些shell命令的 man rpm
查看>>
XenServer 6.0发布
查看>>
提高工作效率的方法之“20分钟理论”
查看>>
docker CE&&EE版本centos安装
查看>>
浅谈URL生成方式的演变
查看>>
Linux下ssl+http 实现 HTTPS 访问服务器设置
查看>>
磁盘与文件系统管理之五
查看>>
python学习-递归
查看>>
day:35:netfilter防火墙的管理工具firewalld及iptables备份恢复
查看>>