Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit
Status

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

Sample Output

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.

n个人在任意一个时间段到达,有男有女,求人最多的时候有多少,并且男等于女

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[2][500];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
char op[2];
int x,y;
memset(a,0,sizeof(a));
for(int i=0;i<n;i++)
{
scanf("%s%d%d",op,&x,&y);
int t=1;
if(op[0]=='M') t=0;
for(int j=x;j<=y;j++)
a[t][j]++;
}
int ans=0;
for(int i=0;i<=366;i++)
ans=max(ans,min(a[0][i],a[1][i]));
printf("%d\n",ans*2);
}
return 0;
}

Codeforces--629B--Far Relative’s Problem(模拟)的更多相关文章

  1. Codeforces Round #343 (Div. 2)-629A. Far Relative’s Birthday Cake 629B. Far Relative’s Problem

    A. Far Relative's Birthday Cake time limit per test 1 second memory limit per test 256 megabytes inp ...

  2. Codeforces 798C. Mike and gcd problem 模拟构造 数组gcd大于1

    C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: s ...

  3. 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 ...

  4. codeforces 629BFar Relative’s Problem

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

  5. 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 ...

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

    题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include< ...

  7. codeforces 723B Text Document Analysis(字符串模拟,)

    题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...

  8. Codeforces Round #304 C(Div. 2)(模拟)

    题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...

  9. Codeforces 749C:Voting(暴力模拟)

    http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...

随机推荐

  1. Python语言之模块

    模块基本上就是一个包含了所有你定义的函数和变量的文件.它用处在于使你你能在别的程序中重用它提供的功能和服务. 1.模块的使用方法 模块的文件名必须以.py作为扩展名. 当我们需要使用某个模块时,我们需 ...

  2. JavaScript面试题链接汇总

    最新JavaScript笔试题(含答案) - 爱思资源网 前端工程师面试问题列表 - 爱思资源网 腾讯最新前端面试题记录分享 - 爱思资源网 优酷前端JS部分面试题 - 爱思资源网 百度校园招聘web ...

  3. 【sqli-labs】 less44 POST -Error based -String -Stacked Blind(POST型基于盲注的堆叠字符型注入)

    盲注漏洞,登陆失败和注入失败显示的同一个页面 可以用sleep函数通过延时判断是否闭合引号成功 这个方法有一点不好的地方在于,并不能去控制延时,延时的时间取决于users表中的数据数量和sleep函数 ...

  4. 关于Python中的类普通继承与super函数继承

    关于Python中的类普通继承与super函数继承 1.super只能用于新式类 2.多重继承super可以保公共父类仅被执行一次 一.首先看下普通继承的写法 二.再看看super继承的写法 参考链接 ...

  5. iOS 中可用的受信任根证书列表

    iOS 中可用的受信任根证书列表 iOS 受信任证书存储区中包含随 iOS 一并预装的受信任根证书. 关于信任和证书 以下所列的各个 iOS 受信任证书存储区均包含三类证书: “可信”的证书用于建立信 ...

  6. vino-server服务是啥服务

    近期接手一个项目,开始梳理服务器,突然发现有个进程是开启5900远程桌面端口的, 在不知情的情况下怕被人给利用了,啥也不说,先干掉再说. server端开启vino-server,允许别人查看自己的桌 ...

  7. MATLAB学习笔记之界面基本操作

    一.命令窗口 1.对于较长的命令,可以用...连接符将断开的命令连接 s=/+/+/4 ... +/+/ 注意: 连接符...与表达式之间要留一个空格: 对于单引号内的字符串必须在一行完全引起来. a ...

  8. linux 的sed命令解释 sed ':t;N;s/\n/,/;b t' 将换行符换成逗号

    linux 的sed命令解释 sed ':t;N;s/\n/,/;b t' 将换行符换成逗号 实现的功能是吧换行符换成逗号了,自己试验过. 求解释,:t N b t 都是什么意思??? :t 定义la ...

  9. [C#] Linq 动态条件查询

    应用背景:以货品为例,在基础数据中配置货品的判断规则,要根据这个规则筛选出符合条件的集合. 创建货品类 public class Product { public string Name { get; ...

  10. 阅读《JavaScript设计模式》第二章心得

    面向对象编程 面向对象编程就是将你的需求抽象成一个对象.然后针对这个对象分析其特征(属性)与动作(方法).这个对象我们称之为类.面向对象编程思想其中的一个特点就是封装. 1.私有属性.私有方法.特权方 ...