Why am I getting TLE in WEIGHTBL?

My code
Link to my solution.
Please help!
Thanks in advance :blush:

Heyy I can give the code in C++…If u r able to undestand bcoz i didn’t code in java

Yes please!

Use Fast IO.

1 Like

I got the same error. It’s because “Scanner” class is rather slow to take input so use Fast IO (Buffered reader). Check this link out Fast I/O in Java in Competitive Programming - GeeksforGeeks

1 Like

Heyy ,it is showing TLE bcoz scanner class has slow input/output and for the large input it was showing tle to you. You can read some gfg article for fast input/output in java
Or you can check out my solution

https://www.codechef.com/viewsolution/44048216

1 Like

Thanks a lot!

Thanks a bunch :blush:

Got it! Thanks