|
|
вернуться в форумTime limit #11 Послано bilac 24 сен 2014 00:39 import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; import java.io.BufferedReader; import java.io.InputStreamReader; public class hgg { /** * @param args */ public static ArrayList<concho> listcho = new ArrayList<concho>(); public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int a = sc.nextInt(); for (int i = 0; i < a; i++) { listcho.add(new concho(sc.nextInt(),sc.nextInt())); } Collections.sort(listcho, new Comparator<concho>() { public int compare(concho o1, concho o2) { // TODO Auto-generated method stub if(o1.kg<o2.kg) return 1; if(o1.kg>o2.kg) return -1; return 0; } }); for (concho item : listcho) { System.out.println(item.tuoi+" "+item.kg); } } public static class concho { int tuoi; int kg; public concho(int t, int k) { tuoi=t; kg=k; } } } |
|
|