TLE when using BufferedInputStream

I’m very new to class BufferedInputStream. So I tried to practice using it with every problem I solved before with Scanner. But every problem come with result TLE (Even in the problem “Life, the Universe, and Everything”. I tried to figure out why this happened for many days but still dont know why. This is my code.

“Life, the Universe, and Everything” :

Sry for my bad English :frowning:

I suppose you want to parse input quicker than with Scanner. Using BufferInputStream is not compfortable IMHO. I guess that problem could be, that the input can end only with \n character (there is no \r character in linux files).

I’m using BufferedReader for input reading and it’s method readLine(), this line I’m splitting with split() method on String and this is quick enought for most problems I solved here.


I agreed that BufferInputStream is very uncomfortable to use. The only reason I use this class because the tutorial said that receive input by this way is the fastest way for Java. I’ll try using BufferReader instead. Thanks for advice :slight_smile: