59082023-10-05 14:14:38mmatedKikötők (35 pont)cpp17Accepted 35/3526ms5488 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,m;
    cin>>n>>m;
    int a[n+1]={0};
    
    int x,y;
    f(i,0,m)
    {
        cin>>x>>y;
        a[x]++;         
        a[x+1]++;
        a[y]--;
        a[y+1]--;
    }
    int maxi=0;
    int maxp=0;
    int c=0;
    f(i,1,n+1)
    {
        c+=a[i];
        if(maxi<c)
        {
            maxi=c;
            maxp=i;
        }
    }
    cout<<maxp<<" "<<maxi;


}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms1896 KiB
2Accepted0/026ms2896 KiB
3Accepted1/13ms2296 KiB
4Accepted1/13ms2504 KiB
5Accepted1/12ms2592 KiB
6Accepted1/12ms2716 KiB
7Accepted1/12ms2932 KiB
8Accepted2/23ms3140 KiB
9Accepted2/23ms3360 KiB
10Accepted2/23ms3584 KiB
11Accepted2/23ms3800 KiB
12Accepted2/23ms4024 KiB
13Accepted2/23ms4120 KiB
14Accepted2/24ms4416 KiB
15Accepted2/24ms4668 KiB
16Accepted2/226ms4860 KiB
17Accepted2/226ms4972 KiB
18Accepted2/24ms5312 KiB
19Accepted2/24ms5396 KiB
20Accepted2/224ms5328 KiB
21Accepted2/226ms5488 KiB
22Accepted2/226ms5484 KiB