Codeforces--629B--Far Relative’s Problem(模拟)
| Time Limit: 2000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
2
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200
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(模拟)的更多相关文章
- 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 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 ...
- 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 ...
- 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 ...
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem
题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include< ...
- codeforces 723B Text Document Analysis(字符串模拟,)
题目链接:http://codeforces.com/problemset/problem/723/B 题目大意: 输入n,给出n个字符的字符串,字符串由 英文字母(大小写都包括). 下划线'_' . ...
- Codeforces Round #304 C(Div. 2)(模拟)
题目链接: http://codeforces.com/problemset/problem/546/C 题意: 总共有n张牌,1手中有k1张分别为:x1, x2, x3, ..xk1,2手中有k2张 ...
- Codeforces 749C:Voting(暴力模拟)
http://codeforces.com/problemset/problem/749/C 题意:有n个人投票,分为 D 和 R 两派,从1~n的顺序投票,轮到某人投票的时候,他可以将对方的一个人K ...
随机推荐
- 用sed替换含反斜(\)的字符串
今天在linux替换配置文件时,test文件里有一个字符串 e:\ 需要换成/usr/home/ 用了sed命令:sed -i "s?e:\\?/usr/home/?g" test ...
- antiSMASH数据库:微生物次生代谢物合成基因组簇查询和预测
2017年4月28日,核酸研究(Nucleic Acids Research)杂志上,在线公布了一个可搜索微生物次生代谢物合成基因组簇的综合性数据库antiSMASH数据库 4.0版,前3版年均引用2 ...
- CAD在网页中如何得到用户自定义事件的参数?
主要用到函数说明: _DMxDrawX::CustomEventParam 得到用户自定义事件的参数. js代码实现如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
- Linux快速入门教程-进程管理ipcs命令学习
使用Linux系统必备的技能之一就是Linux进程管理,系统运行的过程正是无数进程在运行的过程.这些进程的运行需要占用系统的内存等资源,做好系统进程的管理,对于我们合理分配.使用系统资源有非常大的意义 ...
- es6-let/var/const
const和var区别 for(let i=0;i<3;i++) { console.log(i); } console.log(i); for(var i=0;i<3;i++) { co ...
- cvpr2016论文
http://openaccess.thecvf.com/ICCV2017.py http://openaccess.thecvf.com/CVPR2017.py http://www.cv-foun ...
- c++ map: 使用struct或者数组做value
Notice 如果是program中有两个map对象,可能你需要两个map iterator,但是注意两个iter object不能命名一样,可以分别为iter1, iter2 Example #in ...
- NTP测试1
ntp server A : 10.101.75.8 B : 10.101.75.38 B: [root@r10n16313.sqa.zmf /home/ahao.mah] #cat /etc/ntp ...
- 2977,3110 二叉堆练习1,3——codevs
二叉堆练习1 题目描述 Description 已知一个二叉树,判断它是否为二叉堆(小根堆) 输入描述 Input Description 二叉树的节点数N和N个节点(按层输入) 输出描述 Outpu ...
- Capture the Flag ZOJ - 3879(模拟题)
In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are us ...