47672023-03-31 11:30:01EyusieLeghosszabb béke (75 pont)cpp17Wrong answer 23/75217ms4152 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    iostream::sync_with_stdio(0);
    cin.tie();
    int n, k;
    cin >> n >> k;
    bool* a = new bool[n] { 0 };
    int m, l;
    for(int i = 0; i < k; i++)
    {
        cin >> m >> l;
        fill(a+m, a+l+1,1);
    }
    int mx = 0;
    int counter = 0;
    int indmx = 0;
    int indcur = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i])
        {
            if(mx < counter)
            {
                indmx = indcur;
                mx = counter;
            }
            counter = 0;
        }
        else
        {
            if(counter == 0)
            {
                indcur = i;
                counter++;
            }
            else counter++;
        }
    }
    if(mx < counter)
    {
        mx = counter;
        indmx = indcur;
    }
    if(mx == 0)
    {
        cout << "-1";
    }
    else cout << mx << " " << indmx;
}
SubtaskSumTestVerdictTimeMemory
base23/75
1Accepted0/03ms1828 KiB
2Wrong answer0/032ms2252 KiB
3Wrong answer0/33ms2232 KiB
4Wrong answer0/33ms2592 KiB
5Wrong answer0/33ms2668 KiB
6Accepted3/33ms2748 KiB
7Wrong answer0/33ms2944 KiB
8Wrong answer0/43ms3084 KiB
9Wrong answer0/43ms3312 KiB
10Wrong answer0/43ms3180 KiB
11Wrong answer0/44ms3176 KiB
12Wrong answer0/44ms3316 KiB
13Wrong answer0/44ms3536 KiB
14Wrong answer0/44ms3616 KiB
15Wrong answer0/44ms3612 KiB
16Accepted4/44ms3884 KiB
17Accepted4/46ms3844 KiB
18Accepted4/49ms3904 KiB
19Wrong answer0/437ms3952 KiB
20Accepted4/4146ms3900 KiB
21Time limit exceeded0/4217ms3900 KiB
22Accepted4/4134ms4152 KiB