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 1510. Order

JAVA AC with LIST with it's length set
Posted by Roman Samokhin 10 Jan 2015 06:06
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class main{
    public static void main(String[]args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = Integer.parseInt(in.readLine());
        List<Integer> h = new ArrayList<>(n);
        for (int i = 0 ; i < n ; i++){
            int t = Integer.parseInt(in.readLine());
            h.add(t);
        }
        Collections.sort(h);
        out.println(h.get(n/2));
        out.flush();
    }
}

but it gives MLE  21 with
 List<Integer> h = new ArrayList<>();
Re: JAVA AC with LIST with it's length set
Posted by Noob 10 Jan 2015 13:22
int[] h = new int[n];