78702024-01-11 14:31:27AblablablaLeghosszabb béke (75 pont)cpp17Wrong answer 33/7565ms4592 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> szamok(n + 1, 0);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--;

        szamok[a]++;
        szamok[b]--;
    }

    vector<bool> jelenleg(n, 0);
    int akt = 0;
    for(int i = 0; i < n; i++){
        akt += szamok[i];
        jelenleg[i] = (akt == 0);
    }

    int kezdes = 0;
    int maxi = 0;
    int maxInd = -1;
    bool volt = 0;

    for(int i = 0; i < n; i++){
        if(jelenleg[i]){
            volt = 1;
            continue;
        }

        int hossz = i - kezdes;
        if(hossz > maxi){
            maxi = hossz;
            maxInd = kezdes;
        }
        kezdes = i + 1;
    }

    if(volt){
        cout << maxi << " " << maxInd + 1 << "\n";
    } else{
        cout << "-1\n";
    }
}
SubtaskSumTestVerdictTimeMemory
base33/75
1Accepted0/03ms1812 KiB
2Wrong answer0/065ms2760 KiB
3Accepted3/33ms2268 KiB
4Accepted3/33ms2428 KiB
5Wrong answer0/33ms2668 KiB
6Accepted3/33ms2920 KiB
7Wrong answer0/33ms3016 KiB
8Wrong answer0/43ms3096 KiB
9Wrong answer0/43ms3300 KiB
10Wrong answer0/43ms3280 KiB
11Wrong answer0/46ms3368 KiB
12Wrong answer0/48ms3488 KiB
13Wrong answer0/46ms3744 KiB
14Wrong answer0/46ms3688 KiB
15Wrong answer0/48ms3612 KiB
16Accepted4/48ms3848 KiB
17Accepted4/48ms3780 KiB
18Accepted4/48ms3648 KiB
19Wrong answer0/459ms4196 KiB
20Accepted4/461ms4292 KiB
21Accepted4/459ms4504 KiB
22Accepted4/461ms4592 KiB