zoukankan      html  css  js  c++  java
  • codeforces 677A A. Vanya and Fence(水题)

    题目链接:

    A. Vanya and Fence

    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    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?

     
    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.

     
    Examples
     
    input
    3 7
    4 5 14
    output
    4
    input
    6 1
    1 1 1 1 1 1
    output
    6
    input
    6 5
    7 6 8 9 10 5
    output
    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<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar(' ');
    }

    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const LL inf=1e10;
    const int N=1e5+15;

    int n,h;
    int a[2000];
    int main()
    {
    read(n);
    read(h);
    int sum=0;
    Riep(n)
    {
        read(a[i]);
        if(a[i]>h)sum+=2;
        else sum++;
    }
    print(sum);
        return 0;
    }
  • 相关阅读:
    基于C#和Asp.NET MVC开发部标视频和苏标主动安全监控平台
    基于Java Netty框架构建高性能的部标808协议的GPS服务器
    交通部796部标平台开发索引
    GPS部标监控平台的功能设计(一)-功能列表
    基于Java Mina框架的部标jt808服务器设计和开发
    基于Asp.NET MVC框架+SignalR +ActiveMQ + Ali OSS 服务构建苏标主动安全智能防控平台
    部标809协议2019版本与2011版本的区别
    出租车Jt/T 905协议与部标1078协议融合的网约车视频监控平台
    基于JT/T 1078协议设计和开发部标视频服务器
    基于Html5+HLS协议播放符合部标1078协议的实时流媒体视频
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5551891.html
Copyright © 2011-2022 走看看