88402024-02-01 15:05:49KristófLeghosszabb béke (75 pont)cpp17Wrong answer 20/7571ms10820 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+1){
            max=m-i+1;
            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
base20/75
1Wrong answer0/03ms2132 KiB
2Accepted0/071ms5216 KiB
3Wrong answer0/33ms3012 KiB
4Wrong answer0/33ms3228 KiB
5Wrong answer0/33ms3316 KiB
6Wrong answer0/33ms3456 KiB
7Wrong answer0/33ms3668 KiB
8Accepted4/43ms3880 KiB
9Accepted4/43ms4020 KiB
10Accepted4/43ms4364 KiB
11Wrong answer0/46ms4404 KiB
12Wrong answer0/48ms4764 KiB
13Wrong answer0/46ms4784 KiB
14Accepted4/46ms5176 KiB
15Accepted4/48ms5136 KiB
16Wrong answer0/48ms5388 KiB
17Wrong answer0/48ms5516 KiB
18Wrong answer0/48ms5740 KiB
19Wrong answer0/464ms7800 KiB
20Wrong answer0/464ms9072 KiB
21Wrong answer0/461ms9948 KiB
22Wrong answer0/464ms10820 KiB