87412024-01-27 15:51:37FarkasZénóLeghosszabb béke (75 pont)pypy3Time limit exceeded 9/75282ms91056 KiB
from sys import stdin

N, M = [int(x) for x in stdin.readline().split()]
napok = [0] * N
for _ in range(M):
	kezdet, veg = [int(x) for x in stdin.readline().split()]
	for nap in range(kezdet-1, veg):
		napok[nap] += 1
napok.append(1)
leghosszabb = 0
elozo_beke = False
for i in range(N):
	beke = napok[i] == 0
	if beke and not elozo_beke:
		szeria = 0
		szeria_eleje = i + 1
	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/043ms76908 KiB
2Time limit exceeded0/0266ms25724 KiB
3Accepted3/341ms77192 KiB
4Accepted3/339ms77572 KiB
5Wrong answer0/346ms78016 KiB
6Accepted3/343ms78340 KiB
7Wrong answer0/339ms77716 KiB
8Wrong answer0/448ms78596 KiB
9Wrong answer0/457ms88192 KiB
10Wrong answer0/468ms89684 KiB
11Wrong answer0/486ms90632 KiB
12Wrong answer0/4111ms90772 KiB
13Wrong answer0/4100ms90768 KiB
14Wrong answer0/4112ms91056 KiB
15Wrong answer0/4127ms90968 KiB
16Time limit exceeded0/4256ms27180 KiB
17Time limit exceeded0/4282ms27300 KiB
18Time limit exceeded0/4275ms27428 KiB
19Time limit exceeded0/4279ms28080 KiB
20Time limit exceeded0/4270ms28344 KiB
21Time limit exceeded0/4266ms28320 KiB
22Time limit exceeded0/4273ms28884 KiB