Vanya and Fence
Vanya and his friends are walking along the fence of height hhh and they do not want the guard to notice them. In order to achieve this the height of each of the friends should not exceed h. If the height of some person is greater than hhh he can bend down and then he surely won’t be noticed by the guard. The height of the iii-th person is equal to aaai.
Consider the width of the person walking as usual to be equal to 111, while the width of the bent person equals 222. Friends want to talk to each other while walking, so they would like to walk in a single row. What is the minimum width of the road, such that friends can walk in a row and remain unattended by the guard?
Input
The first line of the input contains two integers n and h (

Vanya和他的朋友们正沿着高度为h的栅栏行走,为了避免被守卫发现,每个人的高度不应超过h。如果某人的身高超过h,他可以弯腰,这样就不会被看见。朋友们希望并排行走进行交谈,求最小宽度的路面,使得他们能排列成一行并避开守卫的注意。输入包含朋友人数n和栅栏高度h,以及每个人的身高ai。输出是最小的可行路面宽度。解决方案是根据身高是否超过栅栏高度来累加路面宽度,若超过则加2,否则加1。
最低0.47元/天 解锁文章
638

被折叠的 条评论
为什么被折叠?



