30 lines
678 B
Python
30 lines
678 B
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
import math
|
|
|
|
def better_algo_X(A, k):
|
|
l = -1 * math.inf
|
|
r = math.inf
|
|
for i in range(0, len(A)):
|
|
c = 0
|
|
for j in range(i, len(A)):
|
|
print("i =", i, "j =", j, "c =", c)
|
|
if A[i] == A[j]:
|
|
c = c + 1
|
|
if c >= k:
|
|
if r - l > j - i:
|
|
l = i
|
|
r = j
|
|
print("l =", l, "r = ", r)
|
|
break
|
|
return [l, r]
|
|
|
|
A = []
|
|
for line in sys.stdin:
|
|
line = line.strip()
|
|
if line == '' or line == '\n':
|
|
break
|
|
A.append(int(line))
|
|
|
|
print(better_algo_X(A[1:], A[0]))
|