Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- Team tab[] = new Team[n];
- for (int i = 0; i < n; i++) {
- String s = in.next();
- int p = in.nextInt();
- int x = in.nextInt();
- int y = in.nextInt();
- tab[i] = new Team(s,p,(int) Math.max(x, y) - (int) Math.min(x, y),x);
- }
- Arrays.sort(tab, new TeamComparator());
- System.out.println(tab[tab.length-1].teamName);
- }
- }
- class Team
- {
- public String teamName;
- public int totalPoints;
- public int differenceGoals;
- public int goals;
- public Team()
- {}
- public Team(String teamName, int totalPoints, int differenceGoals, int goals)
- {
- this.teamName = teamName;
- this.totalPoints = totalPoints;
- this.differenceGoals = differenceGoals;
- this.goals = goals;
- }
- }
- class TeamComparator implements Comparator<Team>
- {
- @Override
- public int compare(Team o1, Team o2)
- {
- int retour = Integer.compare(o1.totalPoints, o2.totalPoints);
- if(retour == 0)
- retour = Integer.compare(o1.differenceGoals, o2.differenceGoals);
- if(retour == 0)
- retour = Integer.compare(o1.goals, o2.goals);
- return retour;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement