243952026-02-11 07:35:28mzperxLeghosszabb béke (75 pont)python3Time limit exceeded 34/75270ms7308 KiB
hossz, db = [int(x) for x in input().split()]
évek = [0] * (hossz+1)
for _ in range(db):
    kezdet, vég = [int(x) for x in input().split()]
    évek[kezdet] += 1
    évek[vég+1] -= 1
# print(évek)
'''
évek = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 
-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, -1, 0, -1, 0, 0]
'''
évek.append(1)
stat = [0] * len(évek)
mutató = 0
for i in range(len(évek)):
    mutató += évek[i]
    if mutató > 0:
        stat[i] = mutató

aktmax = [0, 0, 0]
abszmax = [0, 0, 0]
for i in range(1, len(évek)):
    if stat[i] == 0:
        if aktmax[0] == 0:
            aktmax[1] = i
        aktmax[0] += 1
        aktmax[2] = i
    elif aktmax[0] > abszmax[0]:
        abszmax = aktmax[0:3]
        aktmax = [0, 0, 0]
if abszmax[0] == 0:
    print(-1)
else:
    print(abszmax[0], abszmax[1])
SubtaskSumTestVerdictTimeMemory
base34/75
1Accepted0/016ms3204 KiB
2Time limit exceeded0/0270ms6924 KiB
3Runtime error0/316ms3148 KiB
4Accepted3/316ms3120 KiB
5Accepted3/317ms3124 KiB
6Wrong answer0/316ms3124 KiB
7Wrong answer0/316ms3320 KiB
8Wrong answer0/416ms3160 KiB
9Accepted4/418ms3128 KiB
10Accepted4/421ms3128 KiB
11Accepted4/432ms3380 KiB
12Accepted4/441ms3804 KiB
13Accepted4/435ms3696 KiB
14Accepted4/437ms3892 KiB
15Accepted4/441ms3900 KiB
16Runtime error0/416ms3268 KiB
17Runtime error0/417ms3380 KiB
18Runtime error0/417ms3384 KiB
19Time limit exceeded0/4254ms7308 KiB
20Runtime error0/417ms3892 KiB
21Runtime error0/417ms3892 KiB
22Runtime error0/417ms3892 KiB