HDU 4176 Class Statistics

Class Statistics

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 203    Accepted Submission(s): 128


Problem Description
The new principal of Woop Woop Public plans to meet the teaching team to discuss the performance of the classes/teachers and, being a bean counting fundamentalist, he wants to arm himself with some statistics for the meetings.
Your task is to write a program that reads the pupils' marks in each class and generates performance reports for the principal prior to the meetings.
 

Input
The input starts with an integer K (1 <= K <= 100) indicating the number of classes on a line by itself. Each of the following K lines gives a class's data, which starts with an integer N (2 <= N <= 50) indicating the number of pupils in the class. The number of pupils is followed by their marks, given as integers, in the range of zero to one hundred, separated by single spaces.
 

Output
The report for each class consists of two lines.
The first line consists of the sentence: "Class X", where X indicates the class number starting with the value of one.
The second line reports the maximum class mark, minimum class mark and the largest difference between consecutive marks (when sorted in non-decreasing order) in the class using the formats shown in the sample below.
 

Sample Input
  
  
2 5 30 25 76 23 78 6 25 50 70 99 70 90
 

Sample Output
  
  
Class 1 Max 78, Min 23, Largest gap 46 Class 2 Max 99, Min 25, Largest gap 25
 

Source
 


#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>

using namespace std;

#define PB push_back
#define MP make_pair
#define CLR(vis) memset(vis,0,sizeof(vis))
#define MST(vis,pos) memset(vis,pos,sizeof(vis))
#define MAX3(a,b,c) max(a,max(b,c))
#define MAX4(a,b,c,d) max(max(a,b),max(c,d))
#define MIN3(a,b,c) min(a,min(b,c))
#define MIN4(a,b,c,d) min(min(a,b),min(c,d))
#define PI acos(-1.0)
#define INF 0x7FFFFFFF
#define LINF 1000000000000000000LL
#define eps 1e-8

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int k;
    int n;
    cin>>k;
    int a[55];
    int cas=1;
    while(k--)
    {
        cin>>n;
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        int b,c,d=-1;
        sort(a,a+n);
        printf("Class %d\n",cas++);
        b=a[0],c=a[n-1];
        for(int i=1;i<n;i++)
        {
            d=max(d,a[i]-a[i-1]);
        }
        printf("Max %d, Min %d, Largest gap %d\n",c,b,d);

    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值