87422024-01-27 16:07:16FarkasZénóLeghosszabb béke (75 pont)python3Time limit exceeded 9/75284ms19804 KiB
from sys import stdin

N, M = [int(x) for x in stdin.readline().split()]
napok = [0] * N
haboru = set()
for _ in range(M):
	kezdet, veg = [int(x) for x in stdin.readline().split()]
	haboru |= set(range(kezdet, veg+1))
leghosszabb = 0
elozo_beke = False
for i in range(1, N+1):
	beke = i not in haboru
	if beke and not elozo_beke:
		szeria = 0
		szeria_eleje = i
	if beke:
		szeria += 1
	if not beke and elozo_beke:
		if szeria > leghosszabb:
			leghosszabb = szeria
			leghosszabb_eleje = szeria_eleje
	elozo_beke = beke
if leghosszabb > 0:
	print(leghosszabb, leghosszabb_eleje)
else:
	print(-1)
SubtaskSumTestVerdictTimeMemory
base9/75
1Accepted0/017ms11260 KiB
2Time limit exceeded0/0246ms14260 KiB
3Accepted3/317ms11428 KiB
4Accepted3/317ms12012 KiB
5Wrong answer0/317ms12096 KiB
6Accepted3/317ms12252 KiB
7Wrong answer0/317ms12376 KiB
8Wrong answer0/418ms12756 KiB
9Wrong answer0/421ms14172 KiB
10Wrong answer0/452ms14652 KiB
11Time limit exceeded0/4272ms7176 KiB
12Time limit exceeded0/4268ms8480 KiB
13Time limit exceeded0/4270ms8292 KiB
14Time limit exceeded0/4266ms7380 KiB
15Time limit exceeded0/4268ms7484 KiB
16Time limit exceeded0/4268ms11292 KiB
17Time limit exceeded0/4259ms11620 KiB
18Time limit exceeded0/4272ms13948 KiB
19Time limit exceeded0/4256ms17128 KiB
20Time limit exceeded0/4280ms18576 KiB
21Time limit exceeded0/4277ms19768 KiB
22Time limit exceeded0/4284ms19804 KiB