zoukankan      html  css  js  c++  java
  • 武汉科技大学ACM:1005: Soapbear and Honey

    Problem Description

    Soapbear is the mascot of WHUACM team. Like other bears, Soapbear loves honey very much, so he decides to get some honeycombs for honey. There are N honeycombs hanging on some trees, numbered from 1 to N, and the height of honeycomb i is Hi. The height Soapbear can reach the is Hx, so he wonders how many honeycombs he can get at most.

    Input

    There are multiple test cases in the input file. There first line of the input is an integer T indicates the number of the test cases. Each test case starts with a line containing two integer, N and Hx (0 < N <= 200000, 0 < Hx < 200). Next, there is a line of N integers specifying Hi (1 <= i <= N, 0 < Hi < 200).

    Output

    For each test case, output a line with an integer indicates the number of honeycombs Soapbear can get at most.

    Sample Input

    2
    2 180
    170 190
    3 180
    180 170 190
    

    Sample Output

    1
    2
    

    HINT

    Note:Input/Output of scanf/printf is faster than cin/cout, so if a problem has huge input data, use cin will probably get a Time Limit Exceeded.

     1 #include<stdio.h>
     2 #define N 200001
     3 int main()
     4 {
     5     int n,m,Hx=0;
     6     int a[N];
     7     scanf("%d",&n);
     8     while(n--)
     9     {
    10         int result=0;
    11         for(int i=0;i<N;i++)
    12             a[i]=0;
    13         scanf("%d",&m);
    14         scanf("%d",&Hx);
    15         for(int j=0;j<m;j++)
    16         {
    17             scanf("%d",&a[j]);
    18         }
    19         for(int k=0;k<m;k++)
    20         {
    21             if(a[k]<=Hx)
    22                 result++;
    23         }
    24         printf("%d
    ",result);
    25     }
    26     return 1;
    27 }
  • 相关阅读:
    LeetCode(81): 搜索旋转排序数组 II
    2018年6月8日论文阅读
    LeetCode(80):删除排序数组中的重复项 II
    LeetCode(79): 单词搜索
    LeetCode(78):子集
    LeetCode(77):组合
    LeetCode(76): 最小覆盖子串
    LeetCode(75):分类颜色
    LeetCode(74):搜索二维矩阵
    linux 两个查找工具 locate,find
  • 原文地址:https://www.cnblogs.com/liuwt365/p/4174642.html
Copyright © 2011-2022 走看看