### pranav232323's blog

By pranav232323, history, 6 weeks ago,

Hey guys,

The following submission keeps getting TLE even though it has the same time complexity as the official solution ($\mathcal{O}(n)$)

Any ideas about what's going on?

• +8

 » 6 weeks ago, # |   +11 Java's Scanner is extremely slow; use BufferedReader instead.
•  » » 6 weeks ago, # ^ |   +11 I tried using BufferedReader but I still get TLE.
•  » » » 6 weeks ago, # ^ |   +11 Due to the large number of output lines, it turns out you also need to use PrintWriter for more efficient output. See here for an AC version.
•  » » » » 6 weeks ago, # ^ |   +11 Thank you so much, I've been banging my head on this for a while.