47612023-03-31 11:25:40EyusieLeghosszabb béke (75 pont)cpp17Wrong answer 0/75215ms3820 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/03ms1828 KiB
2Wrong answer0/034ms2340 KiB
3Wrong answer0/32ms2104 KiB
4Wrong answer0/33ms2232 KiB
5Wrong answer0/33ms2440 KiB
6Wrong answer0/32ms2408 KiB
7Wrong answer0/33ms2636 KiB
8Wrong answer0/43ms2764 KiB
9Wrong answer0/43ms2844 KiB
10Wrong answer0/43ms2844 KiB
11Wrong answer0/44ms3080 KiB
12Wrong answer0/44ms3012 KiB
13Wrong answer0/44ms3076 KiB
14Wrong answer0/44ms3180 KiB
15Wrong answer0/44ms3196 KiB
16Wrong answer0/46ms3228 KiB
17Wrong answer0/46ms3352 KiB
18Wrong answer0/49ms3572 KiB
19Wrong answer0/439ms3820 KiB
20Wrong answer0/4166ms3716 KiB
21Time limit exceeded0/4215ms3704 KiB
22Wrong answer0/4167ms3708 KiB