88412024-02-01 15:07:03KristófLeghosszabb béke (75 pont)cpp17Wrong answer 23/7570ms6660 KiB
#include <iostream>

using namespace std;

int main()
{
    int nap;
    int n;
    cin>>nap>>n;
    int kezd[n];
    int veg[n];
    int haboru[nap+1];
    for(int i=0;i<nap;i++){
        haboru[i]=-1;
    }
    for(int i=0;i<n;i++){
        cin>>kezd[i];
        cin>>veg[i];

        if(haboru[kezd[i]]<veg[i]){
        haboru[kezd[i]]=veg[i];
    }
    }
    int sege;
    int max=INT8_MIN;
    int kezd2;
    bool haborui=false;
    int m;
    for(int i=1;i<nap;i++){
        if(haboru[i]==-1 && haboru[i+1]==-1 && haborui==false){
             m=i+1;
            while(haboru[m]==-1 && m<=nap){
                m++;
            }

        if(max<m-i){
            max=m-i;
            kezd2=i;
        }
        i=m;

        }
        if(haboru[i]!=-1 && haboru[i]>sege){
            sege=haboru[i];
            haborui=true;
        }

        if(sege==i){
            haborui=false;
        }



    }

    cout<<max<<" "<<kezd2;





    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/75
1Wrong answer0/03ms1880 KiB
2Wrong answer0/070ms4388 KiB
3Wrong answer0/33ms2152 KiB
4Wrong answer0/33ms2552 KiB
5Wrong answer0/33ms2628 KiB
6Accepted3/33ms2916 KiB
7Wrong answer0/33ms2984 KiB
8Wrong answer0/43ms3132 KiB
9Wrong answer0/43ms3236 KiB
10Wrong answer0/43ms3340 KiB
11Wrong answer0/46ms3636 KiB
12Wrong answer0/48ms3684 KiB
13Wrong answer0/46ms3592 KiB
14Wrong answer0/46ms3484 KiB
15Wrong answer0/48ms3632 KiB
16Accepted4/48ms3928 KiB
17Accepted4/48ms3932 KiB
18Accepted4/48ms4232 KiB
19Wrong answer0/464ms6060 KiB
20Wrong answer0/463ms6560 KiB
21Accepted4/461ms6604 KiB
22Accepted4/463ms6660 KiB