zoukankan      html  css  js  c++  java
  • 2017 JUST Programming Contest 3.0 K. Malek and Summer Semester

    K. Malek and Summer Semester
    time limit per test
    1.0 s
    memory limit per test
    256 MB
    input
    standard input
    output
    standard output

    Malek registered n courses for the summer semester. Malek has a success rate m, which means he has to succeed at least in ceil(n × m)courses out of the n courses, in order to consider the summer semester as a successful semester. Malek is considered successful in the ithcourse, if his grade on this course was greater than or equal to 50.

    ceil(x) is the smallest integer greater than or equal to x. For example, ceil(0.95) = 1ceil(4) = 4, and ceil(7.001) = 8.

    Malek will give you his grades in the n courses, and your task is to tell him whether the summer semester was a successful semester or not.

    Input

    The first line contains an integer T (1 ≤ T ≤ 100), where T is the number of test cases.

    The first line of each test case contains an integer n and a real number m (1 ≤ n ≤ 100) (0 < m < 1), where n is the number of courses, and m is the required success rate.

    The second line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the grade of the ith course.

    The success rate m is given with exactly two digits after the decimal point.

    Output

    For each test case, print a single line containing "YES" (without quotes), if the summer semester was a successful semester for Malek. Otherwise, print "NO" (without quotes).

    Example
    input
    2
    5 0.60
    45 46 48 48 50
    5 0.75
    100 99 98 97 100
    
    output
    NO
    YES
    


    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    #define ll long long
    const int maxn=100005;
    int a[105];
    int main()
    {
    //    freopen("in.txt","r",stdin);
        int T,n;
        double m;
        scanf("%d",&T);
        while(T--)
        {
            scanf("%d%lf",&n,&m);
            double guo=n*m;
            int guo1=ceil(guo);
            for(int i=0;i<n;i++)
                scanf("%d",&a[i]);
            int ans=0;
            for(int i=0;i<n;i++)
            {
                if(a[i]>=50)
                    ans++;
            }
            if(ans>=guo1)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
    }



  • 相关阅读:
    C++学习之路(四):线程安全的单例模式
    C++学习之路(三):volatile关键字
    C++学习之路(五):复制构造函数与赋值运算符重载
    类对象作为函数参数进行值传递
    System V共享内存介绍
    关于迭代器失效
    C++学习之路(二):引用
    C++学习之路(一):const与define,结构体对齐,new/delete
    epoll内核源码分析
    Redux中间件之redux-thunk使用详解
  • 原文地址:https://www.cnblogs.com/bryce1010/p/9387155.html
Copyright © 2011-2022 走看看