Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ccc10s1 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = Integer.valueOf(sc.nextLine());
- String[] name = new String[n];
- int[] score = new int[n];
- for (int i = 0; i < n; i++) {
- String line = sc.nextLine();
- String[] part = line.split(" ");
- name[i] = part[0];
- int[] sParts = new int[3];
- for (int j = 0; j < 3; j++)
- sParts[j] = Integer.valueOf(part[j + 1]);
- score[i] = sParts[0] * 2 + sParts[1] * 3 + sParts[2];
- }
- if (n == 0)
- return;
- else if (n == 1) {
- System.out.println(name[0]);
- return;
- }
- int tempInt;
- String tempStr;
- for (int i = 1; i < score.length; i++) {
- for (int j = i; j > 0; j--) {
- if (score[j] > score[j - 1] || (score[j] == score[j - 1] && name[j].compareTo(name[j - 1]) < 0)) {
- tempInt = score[j];
- tempStr = name[j];
- score[j] = score[j - 1];
- name[j] = name[j - 1];
- score[j - 1] = tempInt;
- name[j - 1] = tempStr;
- }
- }
- }
- System.out.println(name[0]);
- System.out.println(name[1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement