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;
    }
  • 相关阅读:
    20182316胡泊 实验5报告
    20182316胡泊 第6周学习总结
    20182316胡泊 第5周学习总结
    20182316胡泊 实验4报告
    20182316胡泊 实验3报告
    20182316胡泊 第4周学习总结
    20182316胡泊 第2,3周学习总结
    实验2报告 胡泊
    《数据结构与面向对象程序设计》第1周学习总结
    实验1报告
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5552972.html
Copyright © 2011-2022 走看看