Created
June 20, 2019 15:27
-
-
Save Canx/995fa54dff20e1256b5eff0d7b02575c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Scanner; | |
import java.util.Set; | |
public class Empezamos { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
boolean fin = false; | |
boolean primero; | |
Integer pisos, letras, asistentes; | |
String piso; | |
String letra; | |
Set<String> participantes = new HashSet<String>(); | |
int asistentes_necesarios; | |
while (in.hasNextLine() & !fin) { | |
pisos = in.nextInt(); | |
letras = in.nextInt(); | |
asistentes = in.nextInt(); | |
in.nextLine(); | |
if (pisos == 0 & letras == 0 & asistentes == 0) | |
fin = true; | |
// tenemos que leer parejas de piso y letra. Añadirlos en una lista y comprobar que no se repiten. | |
else { | |
// System.out.println("Pisos: " + pisos + " Letras:" + letras + " Asistentes: " + asistentes); | |
piso = ""; | |
letra = ""; | |
primero = true; | |
for(String token : in.nextLine().split(" ")) { | |
if (primero) { | |
piso = token; | |
} else { | |
letra = token; | |
//System.out.println(piso + letra); | |
participantes.add(piso + letra); | |
} | |
primero = !primero; | |
} | |
asistentes_necesarios = (int)Math.ceil((pisos*letras) / 2.0); | |
//System.out.println(participantes.size()); | |
//System.out.println("Asistentes necesarios:" + asistentes_necesarios); | |
if (participantes.size() < asistentes_necesarios) { | |
System.out.println("ESPERAMOS"); | |
} | |
else { | |
System.out.println("EMPEZAMOS"); | |
} | |
participantes.clear(); | |
} | |
} | |
in.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment