Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created December 2, 2013 01:00
Show Gist options
  • Save pepet96/7743239 to your computer and use it in GitHub Desktop.
Save pepet96/7743239 to your computer and use it in GitHub Desktop.
General Election
import java.util.Scanner;
public class GeneralElection {
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
int cases = input.nextInt();
for (int i = 1; i <= cases; i++) {
int output = 0, winner = 0;
int[] candidates = new int[input.nextInt()];
int regions = input.nextInt();
for (int m = 1; m <= regions; m++) {
for (int n = 0; n < candidates.length; n++) {
candidates[n] = candidates[n] + input.nextInt();
}
}
for (int n = 0; n < candidates.length; n++) {
if (candidates[n] > output) {
output = candidates[n];
winner = n + 1;
}
}
System.out.println(winner);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment