Блог пользователя obocheton

Автор obocheton, история, 6 лет назад, По-английски

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
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +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 лет назад, скрыть # |
 
Проголосовать: нравится 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