Problem 677A Vanya and Fence (Codeforces 800)

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Vanya and Fence

Vanya and his friends are walking along the fence of height h h h 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 h h h he can bend down and then he surely won’t be noticed by the guard. The height of the i i i-th person is equal to a a ai.

Consider the width of the person walking as usual to be equal to 1 1 1, while the width of the bent person equals 2 2 2. 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 fi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值