Little Chef and Numbers - runtime exception

I strongly believe the following is not against Cde of Conduct rules…

I found that in PROSUM, there is a problem in input - line with N contains whitespaces, so in some cases, this can lead to runtime errors…

I wrote to and also tried to add comment to problem page, but no reply (it’s almost 24 hours…).

Hope it helps :wink:


How are you taking the input? “cin” neglects any type of whitespace , so why runtime error ?

I posted a comment about this too, and it was not approved for some reason. :S
The problem comes for people using BufferedReader in Java (like me), and has to be separately handled (after getting lots of runtime exceptions and guessing it).

1 Like

@atulthetricky: as I wrote “this can lead to runtime errors”, I’m using readLine and the parseInt when there is just one int per line, but it will be the same if someone uses gets and atoi i C… I wrote mainly for coders not using C/C++, same problem can be in python…

I saw a few codes of EgorK and Petr and found that they use a custom InputReader class which is really fast and error free in the above cases. You can try that those class for taking the input in order to avoid these type of errors.