18552022-12-05 15:48:30kdbLeghosszabb béke (75 pont)cpp11Wrong answer 27/7521ms5008 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input)
    {
        os << i << " ";
    }
    os << endl;
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int>vec(n + 1);
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b]--;
    }
    vec[n] = 1;
    int a = 0, b = 1, c = 0, d = 0;
    for (size_t i = 1; i < n + 1; i++)
    {
        vec[i] += vec[i - 1];
        if (vec[i] == 0) a++;
        else
        {
            if (a > c)
            {
                c = a;
                d = b;
            }
            b = i + 1;
            a = 0;
        }
    }
    if (c == 0) cout << -1 << endl;
    else if (c == 1) cout << 1 << " " << d + 1 << endl;
    else cout << c - 1 << " " << d + 1 << endl;
    return 0;
}
/*
50 6
3 20
45 46
28 30
12 20
40 48
8 12

*/
SubtaskSumTestVerdictTimeMemory
base27/75
1Accepted0/03ms1832 KiB
2Wrong answer0/021ms2740 KiB
3Wrong answer0/32ms2256 KiB
4Wrong answer0/32ms2576 KiB
5Wrong answer0/32ms2696 KiB
6Accepted3/32ms2892 KiB
7Wrong answer0/32ms3100 KiB
8Wrong answer0/42ms3208 KiB
9Wrong answer0/42ms3364 KiB
10Wrong answer0/42ms3708 KiB
11Wrong answer0/43ms3856 KiB
12Wrong answer0/44ms3972 KiB
13Wrong answer0/43ms4100 KiB
14Wrong answer0/43ms4004 KiB
15Wrong answer0/44ms4004 KiB
16Accepted4/44ms4180 KiB
17Accepted4/44ms4340 KiB
18Accepted4/44ms4200 KiB
19Wrong answer0/419ms4728 KiB
20Accepted4/419ms4804 KiB
21Accepted4/419ms4800 KiB
22Accepted4/420ms5008 KiB