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

Java. Runtime error on #4 test. Why
Posted by Arderun 24 May 2016 13:55
here is my code

import java.io.PrintWriter;
import java.util.*;

public class Problem1100 {

    public static class Busket extends LinkedList<Long>{}

    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int times = in.nextInt();
        Busket[] list = new Busket[100];
        long id =0;
        int score =0;
        for(int i =0;i<times;i++){
            id = in.nextLong();
            score = in.nextInt();
            boolean insert=false;
            if(list[score]==null){
                Busket busket =  new Busket();
                busket.add(id);
                list[score]=busket;
            } else{
                list[score].add(id);
            }
        }

        StringBuffer result = new StringBuffer();

        for(int i = list.length-1;i>=0; i--){
            Busket busket =list[i];
            if(busket!=null)
            for(Long mId: busket) {
                result.append(mId);
                result.append(" ");
                result.append(i);
                result.append("\n");
            }
        }
        out.println(result.toString());
        out.flush();
    }
}

Edited by author 24.05.2016 13:57

Edited by author 24.05.2016 14:01

Edited by author 24.05.2016 14:09

Edited by author 24.05.2016 14:11
Re: Java. Runtime error on #4 test. Why
Posted by Oleg Baskakov 24 May 2016 14:31
new Busket[100] means indices 0..99. Use [101] for 0..100 indices.

Edited by author 24.05.2016 14:33