It's a really simple problem, and I can't find a test which throws any exception/error. I'm also using input metod which gave me under 6sec on INTEST. I'd really like to know why I get NZEC all the time after submitting. I tried putting everythin in a catch block and it still gave me runtime error. Anyways, here's my code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedOutputStream;
import java.io.PrintStream;
class Main {
public static int parseInt(String str) {
int num = 0;
for (int i = 0, len = str.length(); i < len; ++i) {
num *= 10;
num += str.charAt(i) - '0';
}
return num;
}
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintStream out = new PrintStream(new BufferedOutputStream(System.out));
int count = parseInt(in.readLine());
int[] numbers = new int[1000001];
for (int i = 0; i < count; ++i) {
++numbers[parseInt(in.readLine())];
}
for (int i = 0; i < 1000001; ++i) {
for (int j = 0; j < numbers[i]; ++j) {
out.println(i);
}
}
out.flush();
}
}