42642023-03-20 22:00:21xxxLeghosszabb béke (75 pont)cpp14Wrong answer 30/7565ms5508 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
base30/75
1Accepted0/03ms1808 KiB
2Wrong answer0/065ms2764 KiB
3Accepted3/33ms2112 KiB
4Wrong answer0/33ms2312 KiB
5Wrong answer0/33ms2524 KiB
6Accepted3/33ms2776 KiB
7Wrong answer0/32ms2860 KiB
8Wrong answer0/42ms2860 KiB
9Wrong answer0/43ms3128 KiB
10Wrong answer0/43ms3480 KiB
11Wrong answer0/46ms3444 KiB
12Wrong answer0/47ms3740 KiB
13Wrong answer0/46ms3944 KiB
14Wrong answer0/46ms4216 KiB
15Wrong answer0/47ms4424 KiB
16Accepted4/47ms4304 KiB
17Accepted4/48ms4284 KiB
18Accepted4/48ms4348 KiB
19Wrong answer0/459ms4928 KiB
20Accepted4/459ms5144 KiB
21Accepted4/459ms5508 KiB
22Accepted4/459ms5372 KiB