43622023-03-27 09:18:04PallanekPéterLeghosszabb béke (75 pont)python3Runtime error 48/75129ms14880 KiB
from sys import stdin, stdout
def main():
    N,M=[int(i) for i in input().split()]
    napok=[0]*N
    for i in range(M):
            ab=stdin.readline().split()
            napok[int(ab[0])-1]+=1
            napok[int(ab[1])]-=1

    db=0; mx=0; nap=0; Lnap=0; ossz=0
    for i in range(N):
            ossz+=napok[i]
            if ossz==0:
                db+=1
            else:
                if db>mx:
                    mx=db
                    Lnap=nap
                nap=i+1
                db=0
    if db>mx:
            mx=db
            Lnap=nap
    if mx==0:
        print(-1)
    else:
        print(mx,Lnap+1)
main()
SubtaskSumTestVerdictTimeMemory
base48/75
1Accepted0/017ms11176 KiB
2Accepted0/0129ms12980 KiB
3Runtime error0/317ms11608 KiB
4Accepted3/317ms11748 KiB
5Accepted3/317ms12056 KiB
6Accepted3/317ms12208 KiB
7Accepted3/317ms12500 KiB
8Accepted4/417ms12668 KiB
9Accepted4/417ms12820 KiB
10Accepted4/419ms13000 KiB
11Accepted4/425ms13060 KiB
12Accepted4/428ms13044 KiB
13Accepted4/425ms12932 KiB
14Accepted4/426ms12976 KiB
15Accepted4/428ms13420 KiB
16Runtime error0/417ms13300 KiB
17Runtime error0/417ms13936 KiB
18Runtime error0/417ms13888 KiB
19Accepted4/4119ms14860 KiB
20Runtime error0/417ms14880 KiB
21Runtime error0/417ms14720 KiB
22Runtime error0/417ms14784 KiB