42652023-03-20 22:01:15xxxLeghosszabb béke (75 pont)cpp14Wrong answer 3/7565ms5128 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 = 1;
    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+1;
            cnt = 0;
        }
    }
    if (cntmax == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << cntmax << " " << ans1 << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base3/75
1Wrong answer0/03ms1808 KiB
2Wrong answer0/065ms2712 KiB
3Accepted3/33ms2232 KiB
4Wrong answer0/32ms2472 KiB
5Wrong answer0/33ms2964 KiB
6Wrong answer0/32ms2868 KiB
7Wrong answer0/33ms2980 KiB
8Wrong answer0/43ms2984 KiB
9Wrong answer0/42ms3080 KiB
10Wrong answer0/43ms3180 KiB
11Wrong answer0/46ms3392 KiB
12Wrong answer0/47ms3428 KiB
13Wrong answer0/46ms3688 KiB
14Wrong answer0/46ms3804 KiB
15Wrong answer0/47ms3760 KiB
16Wrong answer0/48ms4068 KiB
17Wrong answer0/48ms4260 KiB
18Wrong answer0/48ms4292 KiB
19Wrong answer0/459ms4852 KiB
20Wrong answer0/459ms5076 KiB
21Wrong answer0/457ms5128 KiB
22Wrong answer0/459ms5076 KiB