Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package clases.pactometro;
- import java.util.LinkedList;
- import java.util.List;
- import us.lsi.common.Files2;
- public class ProblemaMayoriaAbsoluta {
- static Integer mayoriaAbsoluta;
- static List<Integer> resultadoElectoral = new LinkedList<Integer>();
- static List<List<Integer>> incompatibilidades = new LinkedList<List<Integer>>();
- public static Integer getPartido(int i) {
- return resultadoElectoral.get(i);
- }
- public static void iniciar() {
- mayoriaAbsoluta = 0;
- List<String> lineas1 = Files2.getLines("files/resultadoElectoral.txt");
- for(int i = 0 ; i < lineas1.size(); i++) {
- Integer escanios = Integer.parseInt(lineas1.get(i).trim());
- mayoriaAbsoluta += escanios;
- resultadoElectoral.add(escanios);
- }
- mayoriaAbsoluta = (mayoriaAbsoluta / 2) + 1;
- List<String> lineas2 = Files2.getLines("files/incompatibilidades.txt");
- for(int indicePartido = 0; indicePartido < resultadoElectoral.size(); indicePartido++) {
- if(lineas2.size() < indicePartido) {
- break;
- }
- String linea = lineas2.get(indicePartido);
- if(linea == "" || linea == null) {
- continue;
- }
- String[] inc = linea.split(",");
- List<Integer> incompatibilidad = new LinkedList<Integer>();
- for(int k = 0; k < inc.length; k++) {
- incompatibilidad.add(Integer.parseInt(inc[k].trim()));
- }
- incompatibilidades.add(incompatibilidad);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement