博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Far Relative’s Problem (贪心 计算来的最多客人)
阅读量:6194 次
发布时间:2019-06-21

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

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

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

Hint

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.

1 #include
2 int wom[400],man[400],n,max= 0,x,y; 3 char c; 4 int main() 5 { 6 scanf("%d",&n); 7 for(int i = 0;i

 

转载于:https://www.cnblogs.com/yexiaozi/p/5697943.html

你可能感兴趣的文章
安装Discuz
查看>>
论车牌识别与电子警察关系
查看>>
Confluence-企业知识管理与协同软件安装步骤
查看>>
Linux双网卡聚合改造
查看>>
十六周四次课
查看>>
大哥你都有房子有车子还拿着双份工资收入,不能总想让兄弟免费来杭州帮忙啊,开不来这个口啊...
查看>>
联想启天M715E安装硬盘保护系统和网络同传
查看>>
apache日志存放位置(转)
查看>>
HTML5实现文字轮滚
查看>>
2016年一些面试题的整理和心情--1异或到100
查看>>
ospf和rip和静态路由三者的区别?各能实现什么功能?
查看>>
PMP每日一题
查看>>
div css tip自留地
查看>>
Xcode 7 缺少 *.dylib库的解决方法
查看>>
【MyBatis】缓存配置
查看>>
搭建nonde项目结构
查看>>
快讯 | 嘉益仕受邀在工博会期间参与研华物联网共创全球峰会
查看>>
URL Management(网址管理)
查看>>
新手站长们看过来:白话ID
查看>>
Linux基础命令试题——第二周
查看>>