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

Обсуждение задачи 1855. Между светом и тьмой

Can't understand the problem
Послано Skeef79 11 сен 2019 18:29
How is it possible??
Establish 2 4 = 2.6667?

1 2 3 4
1 2 2

(2+2)/2 = 2
Re: Can't understand the problem
Послано Gilles Deleuze 11 сен 2019 20:02
I don't understand what you mean there.

In fact, the problem asks for an interval [l, r] to find the average cost of a sub-interval.

That is, as for the first test case. After two 'change' queries we have cost(1, 2) = 1; cost(2, 3) = 2, cost(3, 4) = 2. Then we are asked for the average on the interval [2, 4] which is (cost(2, 3) + cost(3, 4) + cost(2, 4)) / 3.

So, given an interval [l, r] you are asked to compute:

int64_t n_of_intervals = 0;
int64_t total_sum = 0;
for (int i = l; i < r; ++i)
for (int j = i + 1; j <= r; ++j)
n_of_intervals += 1
total_sum += cost(i, j)
output total_sum / n_of_intervals
Re: Can't understand the problem
Послано Skeef79 12 сен 2019 13:51
Thank you!