Codeforces 629 B. Far Relative’s Problem
2 seconds
256 megabytes
standard input
standard output
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.
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 biinclusive.
Print the maximum number of people that may come to Famil Door's party.
4
M 151 307
F 343 352
F 117 145
M 24 128
2
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200
4
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 <cstdio>
2 #include <cmath>
3 #include <cstring>
4 #include <cstdlib>
5 #include <iostream>
6 #include <sstream>
7 #include <algorithm>
8 #include <string>
9 #include <queue>
10 #include <vector>
11 using namespace std;
12 const int maxn= 500;
13 const double eps= 1e-6;
14 const int inf = 0x3f3f3f3f;
15 typedef long long ll;
16 int n,m,k;
17 int d1[maxn],d2[maxn];
18 char a;
19 int s,e;
20 int main()
21 {
22 scanf("%d",&n);
23 memset(d1,0,sizeof(d1));
24 memset(d2,0,sizeof(d2));
25 for(int i=1;i<=n;i++)
26 {
27 cin>>a>>s>>e;
28 if(a=='M')
29 {
30 for(int i=s;i<=e;i++)
31 d1[i]++;
32 }
33 else if(a=='F')
34 {
35 for(int i=s;i<=e;i++)
36 d2[i]++;
37 }
38 }
39 int ans=0;
40 for(int i=1;i<=366;i++)
41 {
42 int x=min(d1[i],d2[i]);
43 ans=max(ans,x);
44 }
45 printf("%d\n",ans*2);
46 return 0;
47 }
Codeforces 629 B. Far Relative’s Problem的更多相关文章
- Codeforces 629 A. Far Relative’s Birthday Cake
A. Far Relative’s Birthday Cake time limit per test 1 second memory limit per test 256 megabytes ...
- 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 ...
- codeforces 629BFar Relative’s Problem
B. Far Relative’s Problem time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Educational Codeforces Round 40 F. Runner's Problem
Educational Codeforces Round 40 F. Runner's Problem 题意: 给一个$ 3 * m \(的矩阵,问从\)(2,1)$ 出发 走到 \((2,m)\) ...
- Codeforces--629B--Far Relative’s Problem(模拟)
Far Relative's Problem Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I ...
- 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 ...
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem
题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include< ...
- Codeforces 629 E. Famil Door and Roads
题目链接:http://codeforces.com/problemset/problem/629/E 询问这个简单环的期望.考虑将这个环拆成两部分. 令${deep[x]>=deep[y]}$ ...
- Codeforces Beta Round #17 A - Noldbach problem 暴力
A - Noldbach problem 题面链接 http://codeforces.com/contest/17/problem/A 题面 Nick is interested in prime ...
随机推荐
- Building a Space Station POJ - 2031
Building a Space Station POJ - 2031 You are a member of the space station engineering team, and are ...
- MAX(数论)
Description 小C有n个区间,其中第i个区间为[li,ri],小C想从每个区间中各选出一个整数,使得所有选出的数and起来得到的结果最大,请你求出这个值. Input Format 第一行一 ...
- Java技术——Java多线程学习
)适合多个相同程序代码的线程区处理同一资源的情况.比如下面这个买票的例子. //使用Thread实现 public static class MyThread extends Thread{ priv ...
- socketCluster 使用
<html> <head> <title>test</title> <script src="https://cdn.bootcss.c ...
- RSA进阶之两个N的公约数
适用场景: 给你两个n,n1和n2. 两个数都很大,不好分解. 但是这数刚好有质数公因子(试试欧几里得辗转相除跑完之后,就是不断地相除就可以了,4000多位也是很快的),那不就相当于间接的分解出q或者 ...
- Mac 如何删除应用、软件
首先需要跟刚接触Mac的小白分享一下卸载软件常用的两种方法: 1.点击Finder(访达)—应用程序—选择所要删除的软件—拖拽到右下方的废纸篓或者单击右键选择“移除到废纸篓”. 2.打开Launchp ...
- python学习_运算
1.数据类型 1.1数字 整型int,如2 浮点型float,如3.14和314E-2 复数complex,如(-5+4) 1.2布尔值 真或假 1或0 1.3字符串 'hello world' 2. ...
- TopK-微博今日热门话题
大纲 TopK on single node TopK on multiple nodes Realtime topK with low QPS Realtime topK with high QPS ...
- 【bzoj4281】[ONTAK2015]Związek Harcerstwa Bajtockiego 树上倍增+LCA
题目描述 给定一棵有n个点的无根树,相邻的点之间的距离为1,一开始你位于m点.之后你将依次收到k个指令,每个指令包含两个整数d和t,你需要沿着最短路在t步之内(包含t步)走到d点,如果不能走到,则停在 ...
- [NOI2011][bzoj2434] 阿狸的打字机 [AC自动机+dfs序+fail树+树状数组]
题面 传送门 正文 最暴力的 最暴力的方法:把所有询问代表的字符串跑一遍kmp然后输出 稍微优化一下:把所有询问保存起来,把模板串相同的合并,求出next然后匹配 但是这两种方法本质没有区别,都是暴力 ...