61302023-11-02 23:59:47horvathabelKikötők (35 pont)cpp17Accepted 35/3571ms12640 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> pf(n+2,0);
    for (int i=0; i<m;i++){
        int a,b;
        cin>>a>>b;
        pf[a]++;
        pf[a+1]++;
        pf[b+1]--;
        pf[b]--;
    }
    int now=0,ans=0;
    int ansh=0;
    for (int i=0; i<=n+1;i++){
        now+=pf[i];
        if (now>ans){
            ans=now;
            ansh=i;
        }
    }
    cout<<ansh<<" "<<ans;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1808 KiB
2Accepted0/070ms3884 KiB
3Accepted1/13ms3400 KiB
4Accepted1/13ms3596 KiB
5Accepted1/13ms3804 KiB
6Accepted1/12ms3900 KiB
7Accepted1/13ms4132 KiB
8Accepted2/23ms4352 KiB
9Accepted2/23ms4340 KiB
10Accepted2/23ms4448 KiB
11Accepted2/24ms4736 KiB
12Accepted2/24ms4656 KiB
13Accepted2/24ms4704 KiB
14Accepted2/24ms5060 KiB
15Accepted2/26ms5280 KiB
16Accepted2/267ms6760 KiB
17Accepted2/268ms8080 KiB
18Accepted2/27ms8184 KiB
19Accepted2/28ms8532 KiB
20Accepted2/261ms9960 KiB
21Accepted2/271ms11136 KiB
22Accepted2/268ms12640 KiB