50752023-04-14 18:30:23sangerafLeghosszabb béke (75 pont)cpp17Accepted 75/7565ms5112 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m; cin >> n >> m;
    vector<int>px(n+1, 0);
    for(int i=0; i<m; i++){
        int a, b; cin >> a >> b;
        px[a]++;
        px[b+1]--;
    }
    int sum=0, hossz=0, maxi=0, ans=-1;
    for(int i=1; i<=n; i++){
        sum+=px[i];
        if(sum==0){
            hossz++;
            if(hossz>maxi){
                maxi=hossz;
                ans=i;
            }
        }else{
            hossz=0;
        }
    }
    if(maxi==0) cout << -1 << endl;
    else cout << maxi << " " << ans-maxi+1 << endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/065ms2708 KiB
3Accepted3/33ms2212 KiB
4Accepted3/33ms2488 KiB
5Accepted3/33ms2600 KiB
6Accepted3/33ms2856 KiB
7Accepted3/32ms2936 KiB
8Accepted4/43ms3024 KiB
9Accepted4/43ms3268 KiB
10Accepted4/43ms3616 KiB
11Accepted4/46ms3536 KiB
12Accepted4/47ms3904 KiB
13Accepted4/46ms3996 KiB
14Accepted4/46ms4176 KiB
15Accepted4/47ms4472 KiB
16Accepted4/47ms4520 KiB
17Accepted4/48ms4492 KiB
18Accepted4/48ms4492 KiB
19Accepted4/464ms5012 KiB
20Accepted4/459ms5112 KiB
21Accepted4/456ms5108 KiB
22Accepted4/459ms5016 KiB