182932025-10-17 20:54:06birozsLeghosszabb béke (75 pont)pypy3Runtime error 59/75156ms32000 KiB
N,M = map(int,input().split())
T = []
maxveg = 0
for _ in range(M):
    A,B = map(int,input().split())
    if B > maxveg:
        maxveg = B
    T.append([A,B])
T.sort(key=lambda x:[x[0],-x[1]])
if T[0][0] > 1:
    kezdet = 1
    hossz = T[0][0] - 1
else:
    kezdet = 0
    hossz = 0
A = T[0][0]
B = T[0][1]
for i in range(1,M):
    if T[i][0] <= B < T[i][1]:
        A = T[i][0]
        B = T[i][1]
    elif B <= T[i][0]:
        if T[i][0] - B - 1 > hossz:
            hossz = T[i][0] - B - 1
            kezdet = B + 1
        A = T[i][0]
        B = T[i][1]
if N - maxveg > hossz:
    hossz = N - maxveg
    kezdet = maxveg + 1
if hossz == 0:
    print(-1)
else:
    print(hossz,kezdet)
SubtaskSumTestVerdictTimeMemory
base59/75
1Accepted0/046ms19432 KiB
2Runtime error0/0129ms32000 KiB
3Accepted3/339ms19416 KiB
4Accepted3/343ms19552 KiB
5Accepted3/345ms19440 KiB
6Accepted3/343ms19480 KiB
7Accepted3/339ms19636 KiB
8Accepted4/446ms19672 KiB
9Accepted4/446ms19788 KiB
10Accepted4/456ms21100 KiB
11Accepted4/489ms23068 KiB
12Accepted4/4101ms22924 KiB
13Accepted4/493ms22468 KiB
14Accepted4/489ms23012 KiB
15Accepted4/493ms23016 KiB
16Accepted4/4101ms22776 KiB
17Accepted4/4111ms22836 KiB
18Accepted4/4101ms23592 KiB
19Runtime error0/4128ms32000 KiB
20Runtime error0/4156ms32000 KiB
21Runtime error0/4136ms32000 KiB
22Runtime error0/4127ms32000 KiB