zoukankan      html  css  js  c++  java
  • 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 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?

    Input

    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.

    Output

    Print a single integer — the minimum possible valid width of the road.

    Sample Input

    3 7
    4 5 14

    Sample Output

    4

    Hint

    题意

    身高不超过h的话,一般只会占1的宽度,超过的话,体型占2的宽度

    问你n个人,要站成一排的话,最少要多少宽度

    题解:

    水题……

    代码

    #include<bits/stdc++.h>
    using namespace std;
    int n,h,x,ans;
    int main()
    {
        scanf("%d%d",&n,&h);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            ans++;
            if(x>h)ans++;
        }
        cout<<ans<<endl;
    }
  • 相关阅读:
    asp.net 页面定时跳转的小技巧
    获得 Windows phone 设备的信息
    如何自定义ToggleSwitch控件样式(转)
    云推送注意(MSDN链接)
    回顾:线程和进程的区别
    WebGL
    13种提升基于MVVM模式的WP7程序性能的方法(转)
    sample_code
    网址收藏
    Net中de日期格式
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5552972.html
Copyright © 2011-2022 走看看