Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ccc10s1 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. int n = Integer.valueOf(sc.nextLine());
  8. String[] name = new String[n];
  9. int[] score = new int[n];
  10. for (int i = 0; i < n; i++) {
  11. String line = sc.nextLine();
  12. String[] part = line.split(" ");
  13. name[i] = part[0];
  14. int[] sParts = new int[3];
  15. for (int j = 0; j < 3; j++)
  16. sParts[j] = Integer.valueOf(part[j + 1]);
  17. score[i] = sParts[0] * 2 + sParts[1] * 3 + sParts[2];
  18. }
  19. if (n == 0)
  20. return;
  21. else if (n == 1) {
  22. System.out.println(name[0]);
  23. return;
  24. }
  25. int tempInt;
  26. String tempStr;
  27. for (int i = 1; i < score.length; i++) {
  28. for (int j = i; j > 0; j--) {
  29. if (score[j] > score[j - 1] || (score[j] == score[j - 1] && name[j].compareTo(name[j - 1]) < 0)) {
  30. tempInt = score[j];
  31. tempStr = name[j];
  32. score[j] = score[j - 1];
  33. name[j] = name[j - 1];
  34. score[j - 1] = tempInt;
  35. name[j - 1] = tempStr;
  36. }
  37. }
  38. }
  39.  
  40.  
  41. System.out.println(name[0]);
  42. System.out.println(name[1]);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement