B. Far Relative’s Problem

题目连接:

http://www.codeforces.com/contest/629/problem/B

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<bits/stdc++.h>
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<<ans<<endl;
}

Codeforces Round #343 (Div. 2) B. Far Relative’s Problem 暴力的更多相关文章

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

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

  2. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

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

  4. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake【暴力/组合数】

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

  5. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake

    水题 #include<iostream> #include<string> #include<algorithm> #include<cstdlib> ...

  6. Codeforces Round #343 (Div. 2) B

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

  7. Codeforces Round #343 (Div. 2)

    居然补完了 组合 A - Far Relative’s Birthday Cake import java.util.*; import java.io.*; public class Main { ...

  8. Codeforces Round #343 (Div. 2)【A,B水题】

    A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...

  9. Codeforces Round #343 (Div. 2) E. Famil Door and Roads lca 树形dp

    E. Famil Door and Roads 题目连接: http://www.codeforces.com/contest/629/problem/E Description Famil Door ...

随机推荐

  1. python基础===trheading 模块

    '''threading模块''' import threading import time def music(func): for i in range(2): print("[+]i ...

  2. FIS3 大白话【一】

    1.fis3可以用fis.set进行一些全局的配置,包括忽略文件.文件后缀处理类型.源码过滤等等,用fis3.get可以得到配置信息,详见: http://fis.baidu.com/fis3/doc ...

  3. 2015多校第9场 HDU 5405 Sometimes Naive 树链剖分

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5405 题意: 给你一棵n个节点的树,有点权.        要求支持两种操作: 操作1:更改某个节点的 ...

  4. ubuntu在vim编辑时,方向键无法正常使用

    /* 如果在普通用户下. */ [frankie@localhost ~]$ sudo apt-get install vim [frankie@localhost ~]$ cd /etc/vim [ ...

  5. ubuntu 10.04打开错误

    打开ubuntu时,出现的错误如下: Invalid configuration file. File "E:\Ubuntu12.04.vmwarevm\Ubuntu12.04.vmx&qu ...

  6. servlet为什么要配置web.xml

    (1).为Servlet命名:  <servlet>  <servlet-name>servlet1</servlet-name> <- 这是用于,在serv ...

  7. HDU-1934

    Car Plates Competition Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  8. svn命令行

    svn查看某一版本下的某一文件 svn cat -r 版本号 文件的目录 svn 对比两个版本之间的差别 svn diff -r 新版本:旧版本

  9. Sqrt(x)——二分法,防越界

    Implement int sqrt(int x). Compute and return the square root of x. 转自:http://blog.csdn.net/doc_sgl/ ...

  10. 访问Github慢的解决办法

    http://blog.csdn.net/sunsteam/article/details/63253933 http://tool.chinaz.com/dns 151.101.196.249  g ...