题目链接:
1 second
256 megabytes
standard input
standard output
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 题意: 比h高的人宽为2,否则为1,求总的宽度; 思路: 水题一个; AC代码:#include <bits/stdc++.h> /*#include <vector> #include <iostream> #include <queue> #include <cmath> #include <map> #include <cstring> #include <algorithm> #include <cstdio> */ using namespace std; #define Riep(n) for(int i=1;i<=n;i++) #define Riop(n) for(int i=0;i<n;i++) #define Rjep(n) for(int j=1;j<=n;j++) #define Rjop(n) for(int j=0;j<n;j++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<''||CH>'';F= CH=='-',CH=getchar()); for(num=;CH>=''&&CH<='';num=num*+CH-'',CH=getchar()); F && (num=-num); } int stk[], tp; template<class T> inline void print(T p) { if(!p) { puts(""); return; } while(p) stk[++ tp] = p%, p/=; while(tp) putchar(stk[tp--] + ''); putchar('\n'); } const LL mod=1e9+; const double PI=acos(-1.0); const LL inf=1e10; const int N=1e5+; int n,h; int a[]; int main() { read(n); read(h); int sum=; Riep(n) { read(a[i]); if(a[i]>h)sum+=; else sum++; } print(sum); return ; }