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

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

Can anyone Suggest where my logic failed for this question, here is my solution which passed the example test cases, but when run the system test it gives the verdict as failed, Thank you.

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I didn't solve this yet, but I think it's pick or leave dynamic programming problem, but you have to one more dimension to know if the first item picked! so the state is as follow:

F(N, picked) = Max(F(N-2, picked), F(N-1, picked)); 
F(0,0) = 0, F(0,1) = donations[0];