### obocheton's blog

By obocheton, history, 3 months ago,

getting wrong answer in abc172c — Tsundoku.

my logic is that taking topmost book from two stack which has less required time to read. I greedily repeated this step untill both list are empty or time slot is available.

why my approach is wrong?

• +9

 » 3 months ago, # | ← Rev. 2 →   0 3 4 33 a[]={10,20,30} b[]={5,25,1,2} ans=4 (5,25,1,2) Hope it will help:)
 » 3 months ago, # |   +4 Yes it is: 2 2 11 10 1 9 9 Greedy solution will take book with value $9$ and won't be able to take any more, while it is possible to read two books if you take $10$ and $1$
 » 6 weeks ago, # |   0 I've tired solving it by using binary search and cumulative arrays but it still gets wrong answer in 7 test cases. Please help !! https://ideone.com/hKp3EV
•  » » 6 weeks ago, # ^ |   0 Cumulative arrays is correct, but then you do wiered things. Instead you need to check each possible combination of both stacks. One of those combinations result is max number of books.
•  » » » 6 weeks ago, # ^ |   0 Thanks a lot. I've solved it