18562022-12-05 15:53:33kdbLeghosszabb béke (75 pont)cpp11Wrong answer 33/7521ms5220 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 + 2);
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b + 1]--;
    }
    vec[n] = 1;
    int a = 0, b = 0, c = 0, d = 0;
    for (size_t i = 1; i < n + 2; i++)
    {
        vec[i] += vec[i - 1];
        if (vec[i] == 0) a++;
        else
        {
            if (a > c)
            {
                c = a;
                d = b;
            }
            b = i;
            a = 0;
        }
    }
    if (c == 0) cout << -1 << endl;
    else cout << c << " " << d + 1 << endl;
    return 0;
}
/*
50 6
3 20
45 46
28 30
12 20
40 48
8 12

*/
SubtaskSumTestVerdictTimeMemory
base33/75
1Accepted0/03ms1824 KiB
2Wrong answer0/021ms2876 KiB
3Accepted3/32ms2264 KiB
4Accepted3/32ms2432 KiB
5Wrong answer0/32ms2520 KiB
6Accepted3/32ms2648 KiB
7Wrong answer0/32ms2856 KiB
8Wrong answer0/42ms2920 KiB
9Wrong answer0/42ms3212 KiB
10Wrong answer0/42ms3448 KiB
11Wrong answer0/43ms3516 KiB
12Wrong answer0/44ms3788 KiB
13Wrong answer0/43ms4060 KiB
14Wrong answer0/43ms4260 KiB
15Wrong answer0/44ms4464 KiB
16Accepted4/44ms4564 KiB
17Accepted4/44ms4520 KiB
18Accepted4/44ms4412 KiB
19Wrong answer0/419ms4936 KiB
20Accepted4/420ms5132 KiB
21Accepted4/419ms5136 KiB
22Accepted4/420ms5220 KiB