zoukankan      html  css  js  c++  java
  • ACM: 限时训练题解-Epic Professor-水题

      Epic Professor

     

    Dr. Bahosain works as a professor of Computer Science at HU (Hadramout    University).

    After grading his programming exam, he noticed that most of the students have failed. Since this is the last semester for him teaching in Yemen, Dr. Bahosain decided to give bonus marks to all students in a fair way.     He decided to give the same bonus marks to all students without making the mark of any student exceed 100.

    Help Dr. Bahosain by finding the maximum possible number of students that will pass the course after adding the bonus marks.

    A student will pass the course if his mark after adding the bonus marks is more than or equal to 50. Input

    The first line of input contains an integer T (1 ≤ T ≤   1024) that represents the number of test cases.

    The first line of each test case contains one integer N (1 ≤ N ≤ 100) that represents the number of students in Dr. Bahosain’s class.

    The next line contains N space-separated integers between 0 and 100, each representing the initial mark of a student.

    Output

     

    For each test case, print a single line with the maximum number of students that will pass the course.

    Sample Input

    Sample Output

    2

    3

    5

    4

    0 21 83 45 64

    7

    99 50 46 47 48 49 98

    /*
    题意教授打分,给每个同学加相同的分数,不能有超过100分的,学生达到50分就合格。
    问有最多有多少合格的学生。
     
     AC代码: 
    */ 
    
    #include"iostream"
    #include"algorithm"
    #include"cstdio"
    #include"cstring"
    #include"cmath"
    #define MX 100 + 5
    using namespace std;
    
    int a[MX];
    
    bool cmp( int a,int b) {
    	return a>b;
    }
    
    int main() {
    	int T,n,maxx,ans;
    	scanf("%d",&T);
    	while(T--) {
    		maxx=0,ans=0;
    		scanf("%d",&n);
    		for(int i=0; i<n; i++) {
    			scanf("%d",&a[i]);
    			maxx=max(maxx,a[i]);
    		}
    		sort(a,a+n);
    		int add=100-maxx;
    		for(int i=0; i<n; i++) {
    			if(a[i]+add>=50)ans++;
    		}
    		printf("%d
    ",ans);
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    数字图像处理(一)之灰度转换和卷积python实现
    ArcEngine+C# 森林资源仿真系统 核心代码
    Dijkstra和Floyd算法遍历图的核心
    python像操作文件一样操作内存的模块 StringIO
    python操作Redis方法速记
    python中时间处理标准库DateTime加强版库:pendulum
    utittest和pytest中mock的使用详细介绍
    《金字塔原理》 读书笔记
    python轻量级orm框架 peewee常用功能速查
    docker中安装的mysql无法远程连接问题解决
  • 原文地址:https://www.cnblogs.com/HDMaxfun/p/5709432.html
Copyright © 2011-2022 走看看