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.

 #include<cstdio>
int wom[],man[],n,max= ,x,y;
char c;
int main()
{
scanf("%d",&n);
for(int i = ;i<n;i++)
{
scanf("%s %d %d",&c,&x,&y);
if(c == 'M')
{
for(int i = x;i<=y;i++)
{
man[i]++;
}
}
else
{
for(int i = x;i<=y;i++)
{
wom[i]++;
}
}
}
for(int i = ;i<=;i++)
{
if(max < (wom[i]<man[i]?wom[i]:man[i])*)
{
max = *(wom[i]<man[i]?wom[i]:man[i]);
}
}
printf("%d\n",max);
}

Far Relative’s Problem (贪心 计算来的最多客人)的更多相关文章

  1. codeforces 629BFar Relative’s Problem

    B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. Codeforces Round #343 (Div. 2) B. Far Relative’s Problem 暴力

    B. Far Relative's Problem 题目连接: http://www.codeforces.com/contest/629/problem/B Description Famil Do ...

  3. Codeforces 629 B. Far Relative’s Problem

      B. Far Relative’s Problem   time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  4. Codeforces--629B--Far Relative’s Problem(模拟)

    Far Relative's Problem Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I ...

  5. 计算"aabbc"中最多的相同字母数

    package Test; import java.util.HashMap; import java.util.Map; public class test3 { /** * 计算"aab ...

  6. an easy problem(贪心)

    An Easy Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8333   Accepted: 4986 D ...

  7. CF #296 (Div. 1) B. Clique Problem 贪心(构造)

    B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. codeforces 442B B. Andrey and Problem(贪心)

    题目链接: B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input ...

  9. hdu----(5055)Bob and math problem(贪心)

    Bob and math problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

随机推荐

  1. (图论)51NOD 1264 线段相交

    给出平面上两条线段的两个端点,判断这两条线段是否相交(有一个公共点或有部分重合认为相交). 如果相交,输出"Yes",否则输出"No".   输入 第1行:一个 ...

  2. ES高级查询

    Query Content 在查询过程中,除了判断文档是否满足查询条件外,ES还会计算一个_score来标识匹配的程度,旨在判断目标文档和查询条件的匹配有多好 # POST 192.168.100.1 ...

  3. mui 每次页面跳转用mui.openWindow会不会占用很大内存?

    http://ask.dcloud.net.cn/question/5384 不能每次用mui.openWindow.不用的webview要close,一个webview被close后会露出其他没有被 ...

  4. POJ 2234 Nim博弈

    思路: nim博弈裸题 xor一下 //By SiriusRen #include <cstdio> using namespace std; int n,tmp,xx; int main ...

  5. Oracle10g初探DBCA

    Database Configuration Assistant. [oracle@dbsrv3 bin]$ pwd /opt/oracle//bin [oracle@dbsrv3 bin]$ ./d ...

  6. Oracle查看所有表空间的数据使用情况

    -- 查看所有表空间的数据使用情况 SELECT Upper(F.TABLESPACE_NAME) "表空间名", D.TOT_GROOTTE_MB "表空间大小(M)& ...

  7. CentOS 6.5使用:[3]使用xftp传递文件

    先检查CentOS系统是否安装了FTP服务 [root@centos ~]# rpm -qa | grep vsftpd 如果有内容输出,那么恭喜你,你的系统已经安装了ftp服务   如果没有那么按照 ...

  8. AJPFX:关于面向对象的封装

    1.回顾        面向对象 -- 注重的是结果,强调的是具备功能的对象.        面向过程 -- 强调的是函数,注重的实现的过程.        函数:对功能的封装.            ...

  9. [BZOJ2809][Apio2012]dispatching 贪心+可并堆

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2809 我们考虑以每一个节点作为管理者所得的最优答案,一定是优先选择所要薪水少的忍者.那么首 ...

  10. git ---回到过去

    git命令回顾 git checkout /git reset -git reset HEAD~    //~代表回滚到第几个版本.. 有多个的话可以在~后面加个数字 git reset --mixe ...