47632023-03-31 11:27:20EyusieLeghosszabb béke (75 pont)cpp17Wrong answer 23/75215ms4108 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(!a[i])
        {
            if(counter == 0)
            {
                indcur = i;
                counter++;
            }
            else counter++;
        }
    }
    if(mx == 0)
    {
        cout << "-1";
    }
    else cout << mx << " " << indmx;
}
SubtaskSumTestVerdictTimeMemory
base23/75
1Accepted0/03ms1828 KiB
2Wrong answer0/032ms2432 KiB
3Wrong answer0/33ms2280 KiB
4Wrong answer0/33ms2504 KiB
5Wrong answer0/33ms2708 KiB
6Accepted3/33ms2784 KiB
7Wrong answer0/33ms3012 KiB
8Wrong answer0/42ms3020 KiB
9Wrong answer0/43ms3120 KiB
10Wrong answer0/43ms3260 KiB
11Wrong answer0/44ms3620 KiB
12Wrong answer0/44ms3440 KiB
13Wrong answer0/44ms3436 KiB
14Wrong answer0/44ms3564 KiB
15Wrong answer0/44ms3576 KiB
16Accepted4/44ms3932 KiB
17Accepted4/46ms3776 KiB
18Accepted4/410ms4104 KiB
19Wrong answer0/437ms4108 KiB
20Accepted4/4165ms4044 KiB
21Time limit exceeded0/4215ms4048 KiB
22Accepted4/4167ms4048 KiB