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. 购买阿里云ECS+安装宝塔面板+Mac下怎么连接阿里云ECS服务器

    1.购买阿里云ECS 2.重置实例密码 这个有点对用户不友好,实际意思就是设置服务器的root登录密码 3.配置安全组放行端口 因为服务器需要从宝塔网站download安装包,包括一些常用的服务比如S ...

  2. clipboard.js 实现动态获取内容并复制到剪切板

    使用clipboard.js分为以下几个步骤: 1.引入一个clipboard.js的文件: 2.新建一个clipboard对象: 3.点击按钮获取目标对象里面的内容,将其复制到剪切板. 注意:1.目 ...

  3. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)

    以后每做完一场CF,解题报告都写在一起吧   暴力||二分 A - Bear and Elections 题意:有n个候选人,第一个候选人可以贿赂其他人拿到他们的票,问最少要贿赂多少张票第一个人才能赢 ...

  4. 题解报告:hdu 1114 Piggy-Bank(完全背包恰好装满)

    Problem Description Before ACM can do anything, a budget must be prepared and the necessary financia ...

  5. linux下的c程序排版工具:indent 分类: linux 2014-06-14 20:05 720人阅读 评论(0) 收藏

    Linux下有一个方便的c语言程序排版工具,只要选择恰当的参数,可以轻易地使自己的程序具有统一的风格. 当然首先要安装indent,执行命令:apt-get install indent indent ...

  6. Java中的流(3)字符流-Reader和Writer

    java中提供了处理以16位的Unicode码表示的字符流的类,即以Reader和Writer 为基类派生出的一系列类.  1.Reader和Writer  这两个类是抽象类,只是提供了一系列用于字符 ...

  7. jmeter(七)函数

    JMeter函数是一些能够转化在测试树中取样器或者其他配置元件的域的特殊值.一个函数的调用就像这样:${_functionName(var1,var2,var3)},-functionName匹配函数 ...

  8. MySQL-时间(time、date、datetime、timestamp和year)

    情景进入 情境进入: 今天调试某查询页面,偶尔发现一个问题,刚刚插入的数据,没有正常排序显示,经过后台调试sql,发现一个问题??? 经过上面红色对比,不知道你发现问题没,Order by 只是多一个 ...

  9. AJPFX学习Java函数知识总结

    函 数:为了提高代码的复用性,可以将其定义成一个单独的功能,该功能的体现就是java中的函数.函数就是体现之一. java中的函数的定义格式:         修饰符 返回值类型 函数名(参数类型 形 ...

  10. 块级元素的text-align对行内元素和果冻元素(inline-block)的作用

    块级元素社设置了text-align:center以后,对其直接行内元素/果冻元素.继承行内元素/果冻元素都会产生“居中效应”. <style> .test4{ text-align: c ...