ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

Time limit #11
Posted by bilac 24 Sep 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;
        }
    }

}