Applying your logic getting TLE in 2nd subtask.

Can anyone please check this…

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

Why (n-i) will be the answer can you please explain? Why not take the least i for which the condition holds?

@pm_5289 We are considering the **last** i elements so for example if I choose the last 2 boxes, then the index i will be n-2. Hence number of boxes required will be n - (n-2) = 2.

Makes sense, right?

Hi can anyone tell me what’s the problem with my code? I’ve just started doing these practice problems and so my thinking for solving these problems hasn’t yet developed. So this code might look crap but I would greatly appreciate it if someone could point out the exact issue.

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

Thanks.

I think the tallest ones would result in minimum number of boxes required…

This is really nice!

Hey, I tried some minor changes that might speed up the solution and it worked for most of the test cases.

Only got 2 TLE for TCs.

I used PYPY3 compiler.

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

I guess few more changes or using Fast IO from PyRival template could enhance the speed further.

Also try PYPY2, python 2 for further speed improvements.

I m positive, you can get this solution AC.

Getting TLE in python for the same approach…