85332024-01-21 15:37:48FarkasZénóÉrdekes túra (70 pont)python3Accepted 70/70105ms40772 KiB
from sys import stdin
from functools import lru_cache

N = int(stdin.readline())
magassagok = [int(x) for x in stdin.readline().split()]
magassagok.append(magassagok[-1])

darab = 0
leghosszabb = -1
benne = False
mostani_hossz = 0

elozo = magassagok[0]
for i in range(1, N+1):
	mostani = magassagok[i]
	if benne and mostani == elozo:
		benne = False
		leghosszabb = max(leghosszabb, mostani_hossz+1)
		darab += 1
		mostani_hossz = 0
	if mostani != elozo:
		mostani_hossz += 1
		benne = True
	
	elozo = mostani
print(darab)
print(leghosszabb)
SubtaskSumTestVerdictTimeMemory
base70/70
1Accepted0/023ms12080 KiB
2Accepted0/0103ms33332 KiB
3Accepted3/323ms13088 KiB
4Accepted3/321ms12972 KiB
5Accepted3/321ms13120 KiB
6Accepted3/323ms13608 KiB
7Accepted3/321ms13732 KiB
8Accepted3/323ms13856 KiB
9Accepted3/324ms13908 KiB
10Accepted3/324ms13964 KiB
11Accepted3/324ms14040 KiB
12Accepted3/327ms14716 KiB
13Accepted4/427ms14696 KiB
14Accepted4/463ms25992 KiB
15Accepted4/470ms28484 KiB
16Accepted4/476ms29332 KiB
17Accepted4/475ms30576 KiB
18Accepted4/486ms32912 KiB
19Accepted4/494ms37276 KiB
20Accepted4/4105ms38640 KiB
21Accepted4/4104ms40772 KiB
22Accepted4/4100ms36668 KiB