Codeforces--677A--Vanya and Fence

本文介绍了一道编程竞赛题,Vanya和他的朋友们正沿着高度为h的围墙行走,他们希望不被守卫发现。若某人的身高超过h,他可以选择弯腰,以确保不被看到。每个人的宽度要么是正常行走时的1,要么是弯腰时的2。他们想排成一排行走。任务是找出最小的路面宽度,使得朋友们能排成一行且不被守卫发现。输入包含朋友人数n和围墙高度h,以及每个人的高度。输出是最小路面宽度。文章提供了题解思路和代码实现。
摘要由CSDN通过智能技术生成

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

Consider the width of the person walking as usual to be equal to 1, while the width of the bent person is equal to 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?
输入描述:
The first line of the input contains two integers n and h (1 ≤ n ≤ 1000, 1 ≤ h ≤ 1000) — the number of friends and the height of the fence, respectively.

The second line contains n integers ai (1 ≤ ai ≤ 2h), the i-th of them is equal to t

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值