█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2081

Problema 0x43 - Encontrar el borde más largo de una string

  • Autor: aebernalmunoz
  • Fecha: 2020-11-21 19:28:42 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.202 s 13 KBi
#2
Correcto
0.191 s 13 KBi
#3
Correcto
0.202 s 13 KBi
#4
Correcto
0.204 s 13 KBi
#5
Correcto
0.202 s 13 KBi
#6
Correcto
0.226 s 13 KBi
#7
Tiempo límite excedido
0.658 s 17 KBi
#8
Tiempo límite excedido
0.744 s 18 KBi
#9
Tiempo límite excedido
0.877 s 18 KBi
#10
Tiempo límite excedido
0.92 s 19 KBi
#11
Tiempo límite excedido
0.95 s 18 KBi
#12
Correcto
0.68 s 17 KBi
#13
Tiempo límite excedido
0.831 s 18 KBi
#14
Tiempo límite excedido
0.815 s 18 KBi
#15
Tiempo límite excedido
0.868 s 18 KBi
#16
Tiempo límite excedido
1.012 s 17 KBi
#17
Correcto
0.374 s 18 KBi
#18
Incorrecto
0.418 s 18 KBi
#19
Incorrecto
0.412 s 19 KBi
#20
Incorrecto
0.355 s 17 KBi
#21
Correcto
0.462 s 17 KBi
#22
Correcto
0.357 s 18 KBi
Puntos totales: 46 / 100

Código

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

		String s = sc.nextLine();
		int count = 0, len = s.length();
		int nextborder = 1, border, i;
		int largest = 0;
		while ((nextborder = s.indexOf(s.charAt(0), nextborder)) != -1) {
			border = nextborder;
			i = 0;
			count = 0;
			while (border < len && s.charAt(i++) == s.charAt(border++)) {
				count++;
			}
			largest = Math.max(largest, count);
			nextborder++;
		}
		System.out.println(largest);

	}
}