42672023-03-20 22:13:32xxxLeghosszabb béke (75 pont)cpp14Accepted 75/7570ms4996 KiB
#include <bits/stdc++.h>
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> haboru(n+2);
    haboru[n+1] = 1;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        haboru[x]++;
        haboru[y+1]--;
    }

    int cnt = 0, cntmax = 0, temp = 1;
    int ans1;

    for(int i = 1; i <= n+1; i++) {
        haboru[i]+=haboru[i-1];
        if(haboru[i] == 0) {
            cnt++;
        } else {
            if (cnt > cntmax) {
                cntmax = cnt;
                ans1 = temp;
            }
            temp = i+1;
            cnt = 0;
        }
    }
    if (cntmax == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << cntmax << " " << ans1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1820 KiB
2Accepted0/070ms2764 KiB
3Accepted3/33ms2212 KiB
4Accepted3/33ms2460 KiB
5Accepted3/33ms2636 KiB
6Accepted3/33ms2848 KiB
7Accepted3/33ms3084 KiB
8Accepted4/42ms3004 KiB
9Accepted4/43ms3164 KiB
10Accepted4/43ms3396 KiB
11Accepted4/46ms3504 KiB
12Accepted4/47ms3616 KiB
13Accepted4/44ms3864 KiB
14Accepted4/46ms3820 KiB
15Accepted4/47ms3864 KiB
16Accepted4/47ms3868 KiB
17Accepted4/48ms4196 KiB
18Accepted4/48ms4524 KiB
19Accepted4/457ms4996 KiB
20Accepted4/459ms4884 KiB
21Accepted4/457ms4968 KiB
22Accepted4/459ms4968 KiB