Free Cash

题意: 给出n个客人进店的时间(hi,mi),按24小时制,  服务每个人需要1分钟, 求最少需要多少人。

分析:因为服务时间为1分钟, 客人进店的时差也是1分钟, 所以要么同一时间服务多个同时进店的人, 要么随便一个人服务其他仅一个人进店的人。
   不用考虑没服务完一个人又有其他人进店。(差点写搓了)

所以:对时间排序, 求出最大重复时间个数就是答案。


#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#define MAX 1005
#include <complex>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <string>
#define INF 1e8
#define MAX (int)1e5+ 5
using namespace std;
struct Client {
    int h, m;
    bool operator < (const Client &a)const {
        return (h < a.h || (h == a.h && m < a.m) );
    }
    bool operator == (const Client &a)const {
        return h == a.h && m == a.m;
    }
    void in() {
        cin>>h>>m;
    }
    void out() {
        cout<<h<<" "<<m<<endl;
    }
} c[MAX];
int n, ans;
int main() {
    while(cin>>n) {
        for(int i = 0; i < n; i++) {
            c[i].in();
        }
        sort(c, c + n);
        
        int ans = 1, at = 0;
        Client ct; ct.h = 99; ct.m = 99;
        for(int  i =  0; i < n; i++) {
            if(!(c[i] == ct )) {
                ans  = max(ans, at);
                at  = 1;
                ct = c[i];
            } else {
                at ++;
            }
            if(i == n - 1) {
                ans  = max(ans, at);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值