26(16) РТ

 avatar
user_8840555
python
a year ago
986 B
1
Indexable
Never
f = open(r'C:\Users\SnowDrit\Downloads\26(1)\26.15.txt')  # на 1 балл
n = int(f.readline())
tochki = []
for s in f:
    ryad, mesto = map(int,s.split())
    tochki.append([ryad,mesto])
tochki.sort()
cnt = 1
itogi = []
for i in range(1,len(tochki)):
    if tochki[i][0] == tochki[i - 1][0] and (tochki[i][1] - tochki[i - 1][1] )==1:
        cnt +=1
        itogi.append(cnt)
    else:
        cnt = 1
print(max(itogi))
/////////////////////////////////////////////////////////////////////////////////////
f = open(r'C:\Users\SnowDrit\Downloads\26(1)\26.16.txt')  # на 2 балл
n = int(f.readline())
tochki = []
for s in f:
    ryad, mesto = map(int, s.split())
    tochki.append([ryad, mesto])
tochki.sort()
cnt = 1
itogi = []
for i in range(1, len(tochki)):
    if tochki[i][0] == tochki[i - 1][0] and (tochki[i][1] - tochki[i - 1][1]) <= 1:
        cnt += 1
        itogi.append([cnt, tochki[i][0]])
    else:
        cnt = 1
print(max(itogi))