eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Enjoy Arithmetic Progressions

Enjoy Arithmetic Progressions

Young Andrew loves arithmetic progressions. His even younger sister Anya has written a sequence of numbers on a blackboard. Now Andrew wants to split this sequence into several arithmetic progressions. For example, a sequence \textbf{1 2 5 7 9 11 3} can be split into three arithmetic progressions: \textbf{1 2}, \textbf{5 7 9 11} and \textbf{3}. There is another way to split it into three arithmetic progressions (\textbf{1 2}, \textbf{5 7 9} and \textbf{11 3}), but there is no way to split it into two or less progressions. Obviously, Andrew would love to split the sequence into as little progressions as possible. He’s even willing to change some of the numbers so that the resulting number of arithmetic progressions is smaller. But it would be boring to just change all numbers to \textbf{1 2 3} .... So Andrew has decided to assign a score of \textbf{c} to each change operation, and a score of \textbf{p} to each resulting arithmetic progression. If he changes \textbf{n_c} numbers and splits the result into \textbf{n_p} progressions, his total score is \textbf{cn_c} + \textbf{pn_p}. He wants his total score to be as small as possible. \InputFile The first line of the input file contains three integers \textbf{n}, \textbf{1} ≤ \textbf{n} ≤ \textbf{3000} (the length of Anya’s sequence), \textbf{c} and \textbf{p}, \textbf{1} ≤ \textbf{c}, \textbf{p} ≤ \textbf{10000}. The second line of the input file contains \textbf{n} integers between \textbf{-1000} and \textbf{1000}, inclusive --- Anya’s sequence. \OutputFile In the first line of the output file print minimal total score. In the second line print the number of arithmetic progressions that Andrew will form. Then output the progressions themselves, one per line. Each line should start with the number of numbers in the progression, followed by the numbers themselves. Every number should be written either as integer between \textbf{-10^9} and \textbf{10^9}, inclusive, or as a rational number with numerator between \textbf{-10^9} and \textbf{10^9}, inclusive, and denominator between \textbf{2} and \textbf{10^9}, inclusive, with the greatest common divisor of numerator and denominator equal to \textbf{1}. Andrew never uses numbers that can’t be written under above restrictions.
Лимит времени 4 секунды
Лимит использования памяти 256 MiB
Входные данные #1
11 2 5
-100 -100 -100 1 1 2 2 3 100 100 100
Выходные данные #1
19
3
3 -100 -100 -100
5 1 3/2 2 5/2 3
3 100 100 100
Автор Пётр Митричев
Источник Зимняя школа, Харьков 2011, День 8