1005 数据已改,第一名的同学,你已经过了,抱歉。。

Let's go to play

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 764   Accepted Submission(s) : 213

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem Description

Mr.Lin would like to hold a party and invite his friends to this party. He has n friends and each of them can come in a specific range of days of the year from ai to bi.
Mr.Lin wants to arrange a day, he can invite more friends. But he has a strange request that the number of male friends should equal to the number of femal friends.

Input

Multiple sets of test data.

The first line of each input contains a single integer n (1<=n<=5000 )

Then follow n lines. Each line starts with a capital letter 'F' for female and with a capital letter 'M' for male. 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.

Sample Input

4
M 151 307
F 343 352
F 117 145
M 24 128
6
M 128 130
F 128 131
F 131 140
F 131 141
M 131 200
M 140 200

Sample Output

2
4
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MIN(a, b)  (a < b)? a: b
#define MAX_N 6000
using namespace std;
struct node{char sex[2];int begin,end;
}num[MAX_N];
int main()
{int n;while (scanf("%d", &n) != EOF) {int m, fm;for (int i = 0; i < n; i++) {scanf("%s%d%d", &num[i].sex, &num[i].begin, &num[i].end);}int temp = 0;for (int i = 1; i < 367; i++) {int m = 0, fm = 0;for (int j = 0; j < n; j++) {if (num[j].begin <= i && num[j].end >= i) {if (num[j].sex[0] == 'M')    m++;else fm++;}}int a = MIN(m, fm);if (temp <= a)  temp = a;}printf("%d\n", temp * 2);}return 0;
}

转载于:https://www.cnblogs.com/cniwoq/p/6770965.html

杭电 Let's go to play相关推荐

  1. 【杭电ACM】1097 A hard puzzle

    [杭电ACM]1097  A hard puzzle http://acm.hdu.edu.cn/showproblem.php?pid=1097 先用int手写了算法结果竟然wrong answer ...

  2. 【ACM】杭电OJ 1106 函数atoi

    函数atoi是把字符串转化成整数的函数,头文件为 #include "stdlib.h" e.g. 运行环境:Dev-C++ 5.11 杭电1106 调用了sort函数,运行的时间 ...

  3. 【ACM】杭电OJ 2037

    题目链接:杭电OJ 2037 先把b[i]进行排序,然后,b[i]与a[i+1]进行比较. #include <iostream> #include <cstdio> #inc ...

  4. 【ACM】杭电OJ 2020(排序)

    题目链接:杭电OJ 2020 排序可以有冒泡排序,选择排序,或者直接调用函数. 下面是选择排序: #include <stdio.h> #include <math.h> in ...

  5. 【ACM】杭电OJ 2018

    题目链接:杭电OJ 2018 从n>4开始,每一年的牛的数量=前一年的牛的数量+三年前的牛的数量 问:为什么是三年前? 答:假设三年前有一头小牛出生,出生的那一年即为第一年,到了第四年,即三年后 ...

  6. 【ACM】杭电OJ 1005

     题目链接:杭电OJ 1005 超时代码如下(而且开辟的数组空间大小不够): #include <stdio.h> int m[100000]; int f(int n,int a,int ...

  7. 【ACM】杭电OJ 1004

     题目链接:杭电OJ 1004 运行环境:Dev-C++ 5.11 思路: 先把先把num数组全部赋值为1:第一个颜色单独输入,从第二个开始,需要与前面的进行比较,如果前面有相同的颜色,则在目前的nu ...

  8. 【ACM】杭电OJ 2012。

    题目链接:杭电OJ 2012 思路很简单,但是有一种高效算法显示编译错误,不知道为什么 运行环境:VS2017 AC代码: #include <stdio.h> #include < ...

  9. 【ACM】杭电OJ 1003。

    运行环境VS2017  题目链接:杭电OJ 1003 主要思想是: 用d[i]来存放前i项中最大的和,得到end,然后再倒推,得起始的位置begin 然而在程序42行的疑问,大家可以讨论一下吗???? ...

  10. 【ACM】杭电OJ 1241(深度优先搜索小结)

    题目链接:杭电OJ 1241 深度优先搜索问题 深度优先搜索是搜索的手段之一.它从某个状态开始,不断地转移状态直到无法转移,然后回退到前一步的状态,继续转移到其他状态,如此不断重复,直至找到最终的解. ...

最新文章

  1. Linux上安装jdk并配置环境变量
  2. 深度学习之Pytorch基础教程!
  3. 【软件期刊01】2017-02-22
  4. 3说明书_电子产品说明书应该怎么翻译?知行君认为需要注意这3点
  5. Mac下的Mysql无法登陆的问题
  6. python多项式回归_在python中实现多项式回归
  7. 《网络编程》守护进程
  8. swift扩展Extensions
  9. [转]虚方法(virtual)和抽象方法(abstract)的区别
  10. 数据仓库:金融/银行业的分层架构篇
  11. 企业级无线无缝漫游之思创漫游3.0 Plus ,三层漫游
  12. 微信公众号小程序实战开发vue3+nodejs+koa2+mysql+nginx阿里云部署教程
  13. Selective Search学习笔记
  14. Flink【优质】面试题摘录
  15. 中国移动H1S-3光猫首发破解路由器桥接教程
  16. Mybatis从零开始
  17. 申请ssl 验证域名 失败了 中间证书
  18. Java开发需要知道的HTML知识
  19. 教你查询快递物流多次收件的单号
  20. android viewpager无限轮播

热门文章

  1. MFC初探 —— 设置软件开机自启
  2. js 中的 __proto__
  3. AndroidStudio安卓原生开发_UI控件_Spinner用法_下拉选择框---Android原生开发工作笔记100
  4. 大数据之-Hadoop之HDFS_读数据流程_原理篇---大数据之hadoop工作笔记0069
  5. 持续集成部署Jenkins工作笔记0007---配置JDK和Maven并安装Deploy插件
  6. SpringCloud工作笔记075---SpotBugs介绍--优化java代码的质量
  7. TensorFlow工作笔记001---Centos7.3下安装TensorFlow最新版本,基于python2.7.5的,没有编译TensorFlow的源码
  8. SQL之Sort的组合查询
  9. C++流水线的简易实现
  10. linux驱动编写(lcd驱动)