## L2-055 胖达的山头

题目链接：https://pintia.cn/problem-sets/994805046380707840/exam/problems/type/7?problemSetProblemId=1913922872972247050&page=1

题目分析：本题考查**差分数组+前缀和**,同时注意一下**时间换算**哦！

```cpp
#include<bits/stdc++.h>
using namespace std;
//我们可以使用差分数组，然后求前缀和，这样可以极大地优化代码
int to_seconds(string s){
    int h=stoi(s.substr(0,2));
    int m=stoi(s.substr(3,2));
    int sec=stoi(s.substr(6,2));
    return (h*3600+m*60+sec);
}
int main(){
    int n;
    cin>>n;
    vector<int> diff(86402,0);
    string a,b;
    for(int j=0;j<n;j++){
        cin>>a>>b;
        int L=to_seconds(a);
        int R=to_seconds(b);
        diff[L]++;
        diff[R+1]--;//因为是闭区间
    }
    int ans=0;
    int now=0;
    for(int i=0;i<=86399;i++){
        now+=diff[i];
        ans=max(ans,now);
    }
    cout<<ans<<endl;
    return 0;
}
