• E. 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 Nspace-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

    2

    5

    0 21 83 45 64

    7

    99 50 46 47 48 49 98

    Sample Output

    3

    4

    #include <stdio.h>
    #include <stdio.h>
    #include <string.h>
    struct node
    {
        char name[21];
        int t;
        int m;
    } a[110],b;
    
    int main()
    {
        int x,n,i,j;
        scanf("%d",&x);
        while(x--)
        {
            scanf("%d",&n);
            for(i=0; i<n; i++)
            {
                scanf("%s %d %d",a[i].name,&a[i].t,&a[i].m);
            }
            for(i=0; i<n-1; i++)
            {
                for(j=0; j<n-1-i; j++)
                {
                    if(a[j].t<a[j+1].t)
                    {
                        b=a[j];
                        a[j]=a[j+1];
                        a[j+1]=b;
                    }
                    else if(a[j].t==a[j+1].t)
                    {
                        if(a[j].m>a[j+1].m)
                        {
                            b=a[j];
                            a[j]=a[j+1];
                            a[j+1]=b;
                        }
                    }
                }
            }
    
            printf("%s
    ",a[0].name);
        }
        return 0;
    }
    

      

  • 相关阅读:
    在网页中用JavaScript控制DIV进行预览打印
    用Javascript实现汉字生成拼音
    在JavaScript中调用window.print打印指定div
    Bootstrap导航菜单实现
    Sublime快捷键
    概念中的DDD(转载)
    ASP.NET反射 (转载)
    JS倒叙方法
    (c#疑问)static的优点是什么?为什么要使用static 变量或函数??
    SQL游标示例
  • 原文地址:https://www.cnblogs.com/xiaolitongxueyaoshangjin/p/12845600.html
Copyright © 2020-2023  润新知