Japanska buba
A Japanese bug flew into a cave full of obstacles: stalagmites (they are on the cave floor) and stalactites (they hang from the cave roof). The cave is of length N (where N is an even number) and of height H. The first obstacle is a stalagmite, and then stalactites and stalagmites go alternatively. In the picture there is an example cave of length 14 and of height 5 (the picture matches the second test example).
The Japanese bug doesn’t want to avoid the barriers, so it chooses one of the H levels and flies from one side of the cave to the other, and uses its kung-fu skills to batter down all the blocks on the way. For example, if it chooses the forth level up the cave floor from the previous picture, it would demolish eight obstacles.
In this example the bug would be less tired if it chose the first or the fifth level, because it would destroy seven obstacles in that case. The dimensions of the cave and the length of all the obstacles are given. Write a program that determines the smallest possible number of obstacles the bug must batter down in order to pass to the other side, and the number of levels that contain that number.
6 7
1
5
3
3
5
1Output:
2 314 5
1
3
4
2
2
4
3
4
3
3
3
2
3
3
Output:
7 2Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.