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 ...
随机推荐
- metlnfo 5.3.1 sql注入复现
首先还是要说的是metlnfo是伪全局变量机制 所以如下: /admin/include/global.func.php function save_met_cookie(){ global $met ...
- AMD嵌入式G系列SoC协助优化Gizmo 2开发板
http://www.gizmosphere.org/ AMD嵌入式G系列SoC协助优化Gizmo 2开发板 http://news.zol.com.cn/491/4910444.html
- 《gdb调试之基础篇》
<gdb调试之基础篇> http://blog.csdn.net/miss_acha/article/details/42346543
- 对list对象进行排序
List<LjlSevOrdersVO> list = ljlSevOrdersService.findSevForOrders(ljlSevOrdersVO); //查出所有是自愿者的订 ...
- 玩转树莓派 - 修改Raspbian软件源加快软件下载速度
这是 meelo 原创的 玩转树莓派 系列文章 步骤1:登录到Raspbian的命令行界面 步骤2:修改Raspbian的软件源 软件源是Linux系统免费的应用程序安装仓库,很多的应用软件都会这收录 ...
- Partial Views
@Html.Partial("MyPartial") @Html.Partial("MyStronglyTypedPartial", new [] {&qu ...
- highcharts高级画图柱状图和折线图
折线图一枚 $("#z_line").highcharts({ chart: { type: 'line' }, credits: { enabled: false // 禁用版权 ...
- HDMI 电视 点对点 桌面超出屏幕
一直在用电视作显示器,但是没有注意点对点到问题,只是感觉字体发虚.直到今天装win10,桌面会超出屏幕,使用intel控制面板调整分辨率后正常,但是注销或重启会再次回复.百度无果,自己摸索,不仅解决了 ...
- react native 增加react-native-storage
现时需要使用react-native-storage本地存储 第一步:配置storage主文件 mystorage.js import { AsyncStorage } from 'react-nat ...
- 简单邮件传输协议SMTP
1.SMTP是由源地址到目的地址传送邮件的一组规则,用来控制信件的中转方式. 2.SMTP服务器是遵循SMTP协议的发送邮件服务器,用来发送或者中转发出的邮件,客户端通过SMTP命令与SMTP服务器进 ...