|
|
вернуться в форумWA #9; Code review Hi there! Here is my code for this task: https://notabug.org/thrashzone_ua/c_examples/src/master/rock_heap.c Short notes: 1) Cases when there is one or two rocks from input are separated 2) In case amount of rocks is more then 2, I'm checking if there is a sublist in list of rocks with sum(sublist) = sum(list) / 2. If there is such a sublist and the number of sum is even - 0 will be printed, if number is not even - 1; 3) In case there no such sublist - it's time for greedy algorithm. Could you please take a look and comment my code? Or maybe provide with test set, on which it will fail? Thank you in advance. Re: WA #9; Code review So, long story short - do not use greedy algorithm, read and think more about dynamic programming. |
|
|