ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1005. Куча камней

WA #9; Code review
Послано thrashzone 19 дек 2020 16:17
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
Послано thrashzone 20 дек 2020 03:22
So, long story short - do not use greedy algorithm, read and think more about dynamic programming.