Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt();
- if (in.hasNextLine()) {
- in.nextLine();
- }
- String tab[] = new String[N];
- for (int i = 0; i < N; i++)
- {
- tab[i] = in.nextLine();
- }
- //Arrays.sort(tab, new StringComparator());
- System.out.println(tab[0].split(" ")[0]);
- //System.out.println("**GL**");
- }
- }
- class StringComparator implements Comparator<String>
- {
- @Override
- public int compare(String o1, String o2)
- {
- String t[] = o1.split(" ");
- double avant = Double.parseDouble(t[1]);
- double apres = Double.parseDouble(t[2]);
- double fin1 = apres - avant;
- String t2[] = o2.split(" ");
- avant = Double.parseDouble(t2[1]);
- apres = Double.parseDouble(t2[2]);
- double fin2 = apres - avant;
- //return Double.compare(fin1, fin2);
- if(fin1 < fin2)
- return -1;
- else if(fin2 < fin1)
- return 1;
- else
- return 0;
- }
- }
- /*
- import java.util.*;
- import java.io.*;
- import java.math.*;
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int N = in.nextInt();
- boolean fail = false;
- List<Crypto> cryptos = new ArrayList<>();
- if (in.hasNextLine()) {
- in.nextLine();
- }
- for (int i = 0; i < N; i++) {
- String crypto = in.nextLine();
- // System.out.println(crypto);
- String[] tab = crypto.split(" ");
- if(tab.length == 3)
- {
- Crypto cr = new Crypto(Double.parseDouble(tab[1]),Double.parseDouble(tab[2]),tab[0]);
- cryptos.add(cr);
- }
- else
- fail = true;
- }
- if(fail == true)
- System.out.println("NONE");
- else
- {
- Collections.sort(cryptos);
- System.out.println(cryptos.get(0).name);
- }
- }
- static class Crypto implements Comparable<Crypto>
- {
- public double depart;
- public double arrivee;
- public String name;
- public Crypto(double d, double a, String n)
- {
- depart = d;
- arrivee = a;
- name = n;
- }
- public int compareTo(Crypto o) {
- return -1 * Double.compare(arrivee / depart, o.arrivee / o.depart);
- }
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement