87402024-01-27 15:45:02FarkasZénóLeghosszabb béke (75 pont)python3Time limit exceeded 9/75275ms12652 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/017ms11500 KiB
2Time limit exceeded0/0268ms5112 KiB
3Accepted3/317ms11804 KiB
4Accepted3/317ms11800 KiB
5Wrong answer0/318ms11932 KiB
6Accepted3/317ms12180 KiB
7Wrong answer0/317ms12168 KiB
8Wrong answer0/417ms12068 KiB
9Wrong answer0/424ms12532 KiB
10Wrong answer0/482ms12652 KiB
11Time limit exceeded0/4272ms5400 KiB
12Time limit exceeded0/4270ms5624 KiB
13Time limit exceeded0/4275ms5832 KiB
14Time limit exceeded0/4270ms5780 KiB
15Time limit exceeded0/4270ms5964 KiB
16Time limit exceeded0/4266ms6028 KiB
17Time limit exceeded0/4270ms6176 KiB
18Time limit exceeded0/4270ms6488 KiB
19Time limit exceeded0/4266ms6828 KiB
20Time limit exceeded0/4263ms7100 KiB
21Time limit exceeded0/4263ms7120 KiB
22Time limit exceeded0/4270ms7336 KiB