47622023-03-31 11:26:24EyusieLeghosszabb béke (75 pont)cpp17Wrong answer 0/75216ms4256 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++;
            cout << counter << "\n";
        }
    }
    if(mx == 0)
    {
        cout << "-1";
    }
    else cout << mx << " " << indmx;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1696 KiB
2Wrong answer0/034ms2252 KiB
3Wrong answer0/33ms2508 KiB
4Wrong answer0/33ms2476 KiB
5Wrong answer0/33ms2684 KiB
6Wrong answer0/33ms2864 KiB
7Wrong answer0/32ms2828 KiB
8Wrong answer0/42ms2916 KiB
9Wrong answer0/43ms3156 KiB
10Wrong answer0/43ms3276 KiB
11Wrong answer0/44ms3444 KiB
12Wrong answer0/44ms3444 KiB
13Wrong answer0/44ms3700 KiB
14Wrong answer0/44ms3808 KiB
15Wrong answer0/44ms3744 KiB
16Wrong answer0/44ms3764 KiB
17Wrong answer0/46ms3764 KiB
18Wrong answer0/410ms3768 KiB
19Wrong answer0/439ms3952 KiB
20Wrong answer0/4167ms4172 KiB
21Time limit exceeded0/4216ms4256 KiB
22Wrong answer0/4163ms4256 KiB