Codeforces Round #355 (Div. 2) A. Vanya and Fence (水题)
来源:互联网 发布:腾讯云域名有啥用 编辑:程序博客网 时间:2024/06/05 20:35
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 74 5 14
4
6 11 1 1 1 1 1
6
6 57 6 8 9 10 5
11
In the first sample, only person number 3 must bend down, so the required width is equal to 1 + 1 + 2 = 4.
In the second sample, all friends are short enough and no one has to bend, so the width 1 + 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 to2 + 2 + 2 + 2 + 2 + 1 = 11.
题解:水题
AC代码:
#include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<cstdlib> #include<iomanip> #include<vector> #include<list> #include<queue> #include<algorithm> using namespace std;int main(){int n,m;while(cin>>n>>m){int sum=0;for(int i=0;i<n;i++){int a;cin>>a;if(a<=m) sum++;else if(a>m) sum+=2;}printf("%d\n",sum);}return 0;}
- Codeforces Round #355 (Div. 2) A. Vanya and Fence(水题)
- Codeforces Round #355 (Div. 2) A. Vanya and Fence (水题)
- Codeforces Round #355 (Div. 2)- Vanya and Fence(模拟)
- ★【16.6.2】Codeforces Round #355 (Div. 2) A. Vanya and Fence
- A. Vanya and Table(Codeforces Round #308 (Div. 2))
- codeforces 677A Vanya and Fence(水题)
- Codeforces Round #235 (Div. 2) A. Vanya and Cards
- Codeforces Round #308 (Div. 2) A. Vanya and Table
- Codeforces Round #280 (Div. 2)---A. Vanya and Cubes (规律 + 暴力)
- Codeforces Round #280 (Div. 2)A. Vanya and Cubes(简单计算)
- Codeforces Round #355 (Div. 2) B. Vanya and Food Processor
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure
- Codeforces Round #355 (Div. 2) D. Vanya and Treasure
- Codeforces Round #355 (Div. 2)C - Vanya and Label
- Codeforces Round #355 (Div. 2)C. Vanya and Label
- Codeforces Round #355 (Div. 2)D. Vanya and Treasure
- Codeforces Round #355 (Div. 2)E. Vanya and Balloons
- Codeforces Round #355 (Div. 2)C. Vanya and Label
- 关于Fragment的方方面面
- 基因数据处理46之cloud-scale-bwamem安装(compile.pl安装没问题)
- Netbeans学习总结
- 后缀自动机总结
- myeclipse中项目的展示为包格式,文件格式设置
- Codeforces Round #355 (Div. 2) A. Vanya and Fence (水题)
- KeepAlive
- Android进化史
- java类与对象_思维导图总结3
- FCN图像语义分割
- mvn 创建简单的spring项目
- linux 下安装 jetty
- 使用ORCAD-PSpice创建元件模型仿真
- 大一下一点小小的总结