Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.033 s | 7 KBi |
#2 |
Correcto
|
0.021 s | 3 KBi |
#3 |
Correcto
|
0.029 s | 3 KBi |
#4 |
Correcto
|
0.021 s | 3 KBi |
#5 |
Correcto
|
0.02 s | 3 KBi |
#6 |
Correcto
|
0.021 s | 6 KBi |
#7 |
Correcto
|
0.06 s | 3 KBi |
#8 |
Correcto
|
0.026 s | 3 KBi |
#9 |
Correcto
|
0.021 s | 3 KBi |
#10 |
Correcto
|
0.129 s | 3 KBi |
#11 |
Correcto
|
0.179 s | 3 KBi |
#12 |
Correcto
|
0.145 s | 3 KBi |
#13 |
Correcto
|
0.18 s | 3 KBi |
#14 |
Correcto
|
0.139 s | 3 KBi |
#15 |
Correcto
|
0.254 s | 3 KBi |
#16 |
Correcto
|
0.174 s | 3 KBi |
#17 |
Correcto
|
0.136 s | 3 KBi |
#18 |
Correcto
|
0.205 s | 3 KBi |
#19 |
Correcto
|
0.022 s | 3 KBi |
#20 |
Correcto
|
0.167 s | 3 KBi |
#21 |
Correcto
|
0.163 s | 3 KBi |
#22 |
Correcto
|
0.171 s | 3 KBi |
#23 |
Correcto
|
0.02 s | 3 KBi |
#24 |
Correcto
|
0.161 s | 3 KBi |
def find_max_substring(arr, k): if k == 26: return len(arr) i, j = 0, 0 chars = {} answer = 0 length = len(arr) while i < length: while j < length: chars[arr[j]] = chars.get(arr[j], 0) + 1 if len(chars) > k: chars[arr[j]] -= 1 break j += 1 if len(chars) >= k: answer = max(answer, j - i) chars[arr[i]] -= 1 if chars[arr[i]] == 0: del chars[arr[i]] i += 1 return answer s = input() k = int(input()) max_substring = find_max_substring(s, k) print(max_substring)