Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Correcto
|
0.004 s | 11 KBi |
#3 |
Correcto
|
0.004 s | 27 KBi |
#4 |
Correcto
|
0.004 s | 53 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 30 KBi |
#7 |
Correcto
|
0.004 s | 29 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.004 s | 2 KBi |
#10 |
Correcto
|
0.017 s | 1 KBi |
#11 |
Correcto
|
0.092 s | 2 KBi |
#12 |
Correcto
|
0.02 s | 2 KBi |
#13 |
Correcto
|
0.083 s | 2 KBi |
#14 |
Correcto
|
0.018 s | 1 KBi |
#15 |
Correcto
|
0.018 s | 4 KBi |
#16 |
Correcto
|
0.058 s | 3 KBi |
#17 |
Correcto
|
0.019 s | 1 KBi |
#18 |
Correcto
|
0.06 s | 3 KBi |
#19 |
Correcto
|
0.029 s | 3 KBi |
#20 |
Correcto
|
0.044 s | 3 KBi |
#21 |
Correcto
|
0.043 s | 2 KBi |
#22 |
Correcto
|
0.056 s | 67 KBi |
#23 |
Correcto
|
0.026 s | 2 KBi |
#24 |
Correcto
|
0.025 s | 4 KBi |
#include <bits/stdc++.h> using namespace std; int main() { string str; int maxDif, maxLen = 0, i = 0, j = 0; map<char, int> tabla; cin >> str; cin >> maxDif; while (i < str.length() && j < str.length()) { tabla[str[j]]++; // Se supero el limite de caracteres permitido. Terminamos con esta substring y actualizamos nuestros numeros while (tabla.size() > maxDif) { tabla[str[i]]--; if (tabla[str[i]] == 0) { tabla.erase(str[i]); } i++; } maxLen = max(maxLen, j - i + 1); // +1 porque indexamos desde 0 j++; } cout << maxLen << endl; }