Codeforces Round #355 (Div. 2)-A
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 the height of the i-th person.
Print a single integer — the minimum possible valid width of the road.
3 7
4 5 14
4
6 1
1 1 1 1 1 1
6
6 5
7 6 8 9 10 5
11
In the first sample, only person number 3 must bend down, so the required width is equal to1 + 1 + 2 = 4.
In the second sample, all friends are short enough and no one has to bend, so the width1 + 1 + 1 + 1 + 1 + 1 = 6 is enough.
In the third sample, all the persons have to bend, except the last one. The required minimum width of the road is equal to 2 + 2 + 2 + 2 + 2 + 1 = 11.
题意:有N人,还有一个高度,每个人不能超过这个高度H。每个人通过这个高度可以有2种方式,1是当高度低于H时,这个人的宽度占1个单位,2是当高度超过H时,这个人要弯腰通过,这个人占2个单位。问最少的宽度是多少?
思路:很明显,当a[i]<=H时,对答案的贡献是1,否则对答案的贡献是2.
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
typedef long long int LL;
#define INF 0x3f3f3f3f
const int MAXN = +;
int H[MAXN];
int main(){
int n, h;
while (~scanf("%d%d", &n, &h)){
int ans = ;
for (int i = ; i < n; i++){
scanf("%d", &H[i]);
if (H[i]>h){
ans += ;
}
else{
ans += ;
}
}
printf("%d\n", ans);
}
return ;
}
Codeforces Round #355 (Div. 2)-A的更多相关文章
- Codeforces Round #355 (Div. 2)-C
C. Vanya and Label 题目链接:http://codeforces.com/contest/677/problem/C While walking down the street Va ...
- Codeforces Round #355 (Div. 2)-B
B. Vanya and Food Processor 题目链接:http://codeforces.com/contest/677/problem/B Vanya smashes potato in ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块
题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...
- E. Vanya and Balloons Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/E 题意:有n*n矩形,每个格子有一个值(0.1.2.3),你可以在矩形里画一个十字(‘+’形或‘x’形),十字的四 ...
- D. Vanya and Treasure Codeforces Round #355 (Div. 2)
http://codeforces.com/contest/677/problem/D 建颗新树,节点元素包含r.c.dis,第i层包含拥有编号为i的钥匙的所有节点.用i-1层更新i层,逐层更新到底层 ...
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力
D. Vanya and Treasure 题目连接: http://www.codeforces.com/contest/677/problem/D Description Vanya is in ...
- Codeforces Round #355 (Div. 2) C. Vanya and Label 水题
C. Vanya and Label 题目连接: http://www.codeforces.com/contest/677/problem/C Description While walking d ...
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题
B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- 调用c++接口类
调用c++接口类 public class CarDeviceDll { /*对dll库进行一些初始化*/ [DllImport("IDI.dll")] public static ...
- ajax鼠标滚动请求 或 手机往下拉请求
Zepto(function($){ var url = $('.page-url').val(); var cur = false; var href_url = $('.page-url').at ...
- August 27th 2016 Week 35th Saturday
Life is a series of commas, not periods. 人生是一系列的逗号,而不是句号. Sometimes I would rather life to be like a ...
- Oracle读写分离架构
读写分离是架构分布式系统的一个重要思想.不少系统整体处理能力并不能同业务的增长保持同步,因此势必会带来瓶颈,单纯的升级硬件并不能一劳永逸.针对业务类型特点,需要从架构模式上进行一系列的调整,比如业务模 ...
- Maven 在sts不会自动下载包的问题
1.查看maven配置setting.xml是否有设置远程仓库 2.sts是否正确配置指定了setting.xml 3.是否开启线上下载,如下图
- UVA 10252
按照字典序输出最长公共子序列 #include<time.h> #include <cstdio> #include <iostream> #include< ...
- AngularJS 服务(Service)
AngularJS 中你可以创建自己的服务,或使用内建服务. 什么是服务? 在 AngularJS 中,服务是一个函数或对象,可在你的 AngularJS 应用中使用. AngularJS 内建了30 ...
- sqlserver 连接远程数据库小结
A,B两个数据库,不在同一台服务器实例 当需要通过sqlserver语句来实现对远程数据库操作(OPENDATASOURCE): select * from -- 操作类型 OPENDATASOURC ...
- Memcached驱动(C#)
using Memcached.ClientLibrary; using System; using System.Collections.Generic; using System.IO; usin ...
- 【转载】Python编写简易木马程序
转载来自: http://drops.wooyun.org/papers/4751?utm_source=tuicool 使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马. 首先准备好 ...