It is, as far as we are aware, impossible to do fast I/O in Java without going through immense pains. Sorry about that.
It is, however, quite possible to get decent I/O speeds with only small efforts.
There are several things which will cause input in Java to be slow. One such thing is the Scanner class, which even though it is quite handy and easy to use, tends to be very very slow even for such a simple task as reading a stream of integers.
Another very important thing is to always make sure that both input and output are buffered, by using e.g. the BufferedReader and BufferedOutputStream classes.
To simplify matters, we have written a small utility class for you, called Kattio.java. This class provides both input and output functionality, and will be fast enough for any problem on the Judge.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article