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 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 暴力的更多相关文章
- Codeforces Round #343 (Div. 2) B. Far Relative’s Problem
题意:n个人,在规定时间范围内,找到最多有多少对男女能一起出面. 思路:ans=max(2*min(一天中有多少个人能出面)) #include<iostream> #include< ...
- 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 ...
- 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) 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 ...
- Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake
水题 #include<iostream> #include<string> #include<algorithm> #include<cstdlib> ...
- 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 ...
- Codeforces Round #343 (Div. 2)
居然补完了 组合 A - Far Relative’s Birthday Cake import java.util.*; import java.io.*; public class Main { ...
- Codeforces Round #343 (Div. 2)【A,B水题】
A. Far Relative's Birthday Cake 题意: 求在同一行.同一列的巧克力对数. 分析: 水题~样例搞明白再下笔! 代码: #include<iostream> u ...
- 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 ...
随机推荐
- ARM linux的启动部分源代码简略分析【转】
转自:http://www.cnblogs.com/armlinux/archive/2011/11/07/2396784.html ARM linux的启动部分源代码简略分析 以友善之臂的mini2 ...
- 64_a2
arquillian-core-parent-1.1.11-6.fc26.noarch.rpm 10-Feb-2017 13:22 12918 arquillian-core-spi-1.1.11-6 ...
- 【bzoj4552】排序
二分一个值,然后线段树上模拟. #include<bits/stdc++.h> #define lson (o<<1) #define rson (o<<1|1) ...
- BZOJ 4241: 历史研究——莫队 二叉堆
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4241 题意:N个int范围内的数,M次询问一个区间最大的(数字*出现次数)(加权众数),可以 ...
- thinkphp模板常用的方法
thinkphp模板我是看了3.2的文档,对里面的东西过了一遍,然后在写到需要用到模板的东西的时候就有印象,有的能直接回顾,但是有的就可能只知道有这个东西,但是不知道怎么用,所以就重新查手册,这个的话 ...
- JVM 核心机制(类加载器、自定义文件系统类加载器、网络自定义类加载器
- LightOJ - 1370
Bi-shoe and Phi-shoe Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu S ...
- Spring Boot with Docker
翻译自:https://spring.io/guides/gs/spring-boot-docker/ Spring Boot with Docker 这篇教程带你一步步构建一个Docker镜像用来运 ...
- 【JBPM4】判断节点decision 方法1
JPDL <?xml version="1.0" encoding="UTF-8"?> <process key="decision ...
- 【转载】“惊群”,看看nginx是怎么解决它的
原文:http://blog.csdn.net/russell_tao/article/details/7204260 在说nginx前,先来看看什么是“惊群”?简单说来,多线程/多进程(linux下 ...