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

wr #11 - Time limit exceed. Help me...!!!
Posted by Bahodir | {TUIT} | 29 Nov 2014 11:15
import java.util.Scanner;

/**
 * Created by Coder on 25.11.2014.
 */
public class FinalStandings1100_ {
    public static void main(String[] args) {
        Scanner x = new Scanner(System.in);
        int n = x.nextInt();
        int a[][] = new int[n][2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                a[i][j] = x.nextInt();
            }
        }
        int k = 1;
        int d = 0
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n - 1; j++) {
                if (a[j][k] < a[j + 1][k]) {
                    int v = a[j][d];
                    a[j][d] = a[j + 1][d];
                    a[j + 1][d] = v;
                    int c = a[j][k];
                    a[j][k] = a[j + 1][k];
                    a[j + 1][k] = c;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
    }
}