• 杭电 Let's go to play


    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
    ", temp * 2);
        }
        return 0;
    } 
    


  • 相关阅读:
    lodash-es 最小化引入
    shortid id生成器
    结构体声明的方式 及类namespace的前置声明
    结构体中使用 箭头 与 点 的区别
    进入Docker容器的几种方式
    协议分析处理工具ProtoBuf
    PubSub ——“发布/订阅”模式
    在Windows/linux下进行gdb调试
    C++中的域作用符::的作用
    C++ 中常用关键字及其用法
  • 原文地址:https://www.cnblogs.com/cniwoq/p/6770965.html
Copyright © 2020-2023  润新知