Олимпиадный тренинг

Задача 38679. carnations


Задача

Темы:
10 carnations are driven into the plank in a row, so there are 9 consecutive spaces between them. The lengths of the gaps (in a row, from left to right) turned out to be equal
7, 2, 8, 4, 3, 9, 5, 1, 6.
A rope can be stretched between some adjacent studs, we will consider the length of this rope equal to the length of the gap. You need to tie the ropes so that a rope is tied to each stud on at least one side, while the total length of all strings would be minimal.
Write your answer as a sequence of 9 numbers equal to 0 or 1. The number 0 means that there is no rope in the corresponding gap, the number 1 means that there is a rope in this gap.
The condition that at least one string is tied to each carnation means that there are no two zeros in a row in the answer, and also that the first and last character of the answer is 1.
For example, let the task be given 5 carnations and 4 gaps of length 1, 2, 3, 4. The length of the ropes will be minimal if you tie the ropes in gaps 1, 2 and 4. Then the answer should be written as 1101.