42662023-03-20 22:07:05xxxLeghosszabb béke (75 pont)cpp14Wrong answer 50/7564ms5264 KiB
#include <bits/stdc++.h>
using namespace std;


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

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

    for(int i = 1; i <= n; i++) {
        haboru[i]+=haboru[i-1];
        if(haboru[i] == 0) {
            cnt++;
        } else {
            if (cnt > cntmax) {
                cntmax = cnt;
                ans1 = temp;
            }
            temp = i+2;
            cnt = 0;
        }
    }
    if (cntmax == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << cntmax << " " << ans1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/75
1Accepted0/03ms1808 KiB
2Wrong answer0/064ms2768 KiB
3Accepted3/33ms2268 KiB
4Wrong answer0/33ms2400 KiB
5Wrong answer0/33ms2520 KiB
6Accepted3/33ms2696 KiB
7Wrong answer0/33ms2904 KiB
8Wrong answer0/43ms2992 KiB
9Accepted4/43ms3016 KiB
10Accepted4/43ms3096 KiB
11Accepted4/46ms3188 KiB
12Wrong answer0/47ms3472 KiB
13Accepted4/46ms3428 KiB
14Wrong answer0/46ms3476 KiB
15Accepted4/47ms3684 KiB
16Accepted4/48ms4036 KiB
17Accepted4/48ms4364 KiB
18Accepted4/48ms4528 KiB
19Wrong answer0/459ms5040 KiB
20Accepted4/459ms5136 KiB
21Accepted4/457ms5136 KiB
22Accepted4/459ms5264 KiB