(做了整整一天啊啊啊啊啊啊啊啊啊,我也太菜了吧,放弃了放弃了。。。。)1012 The Best Rank (25 分)

To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, we encourage students by emphasizing on their best ranks -- that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student.

为了评估我们第一年CS专业学生的表现,我们只考虑他们三门课程的成绩:C- C编程语言,M- 数学(微积分或线性Algrbra),和E- 英语。同时,我们鼓励学生强调他们最好的队伍 - 也就是说,在三门课程和平均成绩的四个等级中,我们为每个学生打印最佳等级。

For example, The grades of CME and A - Average of 4 students are given as the following:

StudentID  C  M  E  A
310101     98 85 88 90
310102     70 95 88 84
310103     82 87 94 88
310104     91 91 91 91

Then the best ranks for all the students are No.1 since the 1st one has done the best in C Programming Language, while the 2nd one in Mathematics, the 3rd one in English, and the last one in average.

然后,所有学生的最佳排名是No.1,因为第一个在C语言编程方面做得最好,而第二个在数学方面,第三个在英语,最后一个在平均。

Input Specification:

Each input file contains one test case. Each case starts with a line containing 2 numbers N and M (≤2000), which are the total number of students, and the number of students who would check their ranks, respectively. Then N lines follow, each contains a student ID which is a string of 6 digits, followed by the three integer grades (in the range of [0, 100]) of that student in the order of CM and E. Then there are M lines, each containing a student ID.

每个输入文件包含一个测试用例。每个案例都以包含2个数字的行开头NM(≤ 2 0 0 0),这是学生总数,谁会检查他们的行列,分别为学生的数量。然后接下来是N行,每行包含一个学生ID,该学生ID是一个6位数的字符串,然后是该学生的三个整数等级(在[0,100]范围内)的顺序CME。然后有M行,每行包含学生ID。

Output Specification:

For each of the M students, print in one line the best rank for him/her, and the symbol of the corresponding rank, separated by a space.

The priorities of the ranking methods are ordered as A > C > M > E. Hence if there are two or more ways for a student to obtain the same best rank, output the one with the highest priority.

If a student is not on the grading list, simply output N/A.

排名方法的优先级按顺序排列 A > C > M > E。因此,如果学生有两种或更多种方式获得相同的最佳等级,则输出具有最高优先级的学生。

如果学生不在评分列表中,只需输出即可N/A

Sample Input:

5 6
310101 98 85 88
310102 70 95 88
310103 82 87 94
310104 91 91 91
310105 85 90 90
310101
310102
310103
310104
310105
999999

Sample Output:

1 C
1 M
1 E
1 A
3 A
N/A
样例解释
STUDENTIDCMEAverageBEST
310101

stu[0].score[1]=98

min=stu[0].rank[1]=1

stu[0].best=1 

stu[0].score[2]=85

stu[0].rank[2]=5

stu[0].score[3]=88

stu[0].rank[3]=4

stu[0].score[0]=90

stu[0].rank[0]=2

1 C
310102

stu[1].score[1]=70

stu[1].rank[1]=5

stu[1].score[2]=95

min=stu[1].rank[2]=1

stu[1].best=2 

stu[1].score[3]=88

stu[1].rank[3]=4

stu[1].score[0]=84

stu[1].rank[0]=5

1 M
310103

stu[2].score[1]=82

stu[2].rank[1]=4

stu[2].score[2]=87

stu[2].rank[2]=4

stu[2].score[3]=94

min=stu[2].rank[3]=1

stu[2].best=3

stu[2].score[0]=88

stu[2].rank[0]=3

1 E
310104

stu[3].score[1]=91

stu[3].rank[1]=2

stu[3].score[2]=91

stu[3].rank[2]=2

stu[3].score[3]=91

stu[3].rank[3]=2

stu[3].score[0]=91

min=stu[3].rank[0]=1

stu[3].best=0

1 A
310105

stu[4].score[1]=85

stu[4].rank[1]=3

stu[4].score[2]=90

stu[4].rank[2]=3

stu[4].score[3]=90

stu[4].rank[3]=3

stu[4].score[0]=88

min=stu[4].rank[0]=3

stu[4].best=0

3 A
exist [stu[0].id==310101]= 1
exist [stu[1].id==310102]= 2
exist [stu[2].id==310103]= 3
exist [stu[3].id==310104]= 4
exist [stu[4].id==310105]= 5
查询的IDtempbeststu[temp-1].rank[best]c[best]
310101exist[310101]=1stu[0].best=1stu[0].rank[1]=1C
310102exist[310102]=2stu[1].best=2stu[1].rank[2]=1M
310103exist[310103]=3stu[2].best=3stu[2].rank[3]=1E
310104exist[310104]=4stu[3].best=0stu[3].rank[0]=1A
310105exist[310105]=5stu[4].best=0stu[4].rank[0]=3A
#include<iostream>
#include<algorithm>///排序
using namespace std;

struct student
{
    int id,best;///存放6位ID
    int score[4],rank[4];///存放三门课对应的排名
} stu[2001];
int exist[1000000],flag;///exit用于验证是否存在

bool cmp(student a,student b)
{
    return a.score[flag]>b.score[flag];
}///按flag号进行排序

int main()
{
    int n,m,id;
    cin>>n>>m;///n个学生,查m次
    for(int i=0; i<n; i++)
    {
        cin>>stu[i].id>>stu[i].score[1]>>stu[i].score[2]>>stu[i].score[3];
        stu[i].score[0]=(stu[i].score[1]+stu[i].score[2]+stu[i].score[3])/3+0.5;
    }///每输入一次就计算平均值并且四舍五入(+0.5)

    for(flag=0; flag<=3; flag++)
    {
        sort(stu,stu+n,cmp);///对每一门成绩及平均分进行从高到低排序
        stu[0].rank[flag]=1;///排序完将最高成绩设为1
        for(int i=1; i<n; i++)
        {///设置其他学生的排名
            if(stu[i].score[flag]==stu[i-1].score[flag])
                stu[i].rank[flag]=stu[i-1].rank[flag];
        ///如果和后一个同学分数相同,设置排名相同
            stu[i].rank[flag]=i+1;///否则就设置排名为第2,3,4....
        }
    }

    for(int i=0; i<n; i++)
    {
        exist[stu[i].id]=i+1;///存放ID:exist[310101]=1,exist[310102]=2.....
        int min=stu[i].rank[0];
        for(int j=1; j<=3; j++)
        {///对于每一行找stu[i].rank的最小值,因为最小的是最好的
            if(stu[i].rank[j]<min)
            {
                min=stu[i].rank[j];
                stu[i].best=j;
            }
        }
    }

    char c[5]= {'A','C','M','E'};
///优先级A>C>M>E,分配序号0,1,2,3
    for(int i=0; i<m; i++)
    {
        cin>>id;///输入查询ID
        int temp=exist[id];
        if(temp)
        {
            int best=stu[temp-1].best;
            cout<<stu[temp-1].rank[best]<<" "<<c[best]<<endl;
        }
        else///不存在
            cout<<"N/A"<<endl;
    }
}

 

当然,下面是一个完整的Kubernetes YAML 文件,用于部署Apache Hive 2.1.1,它包含了基本的配置、服务、持久卷及访问MySQL数据库的示例: ```yaml # 部署文件 (deployment.yaml) apiVersion: apps/v1 kind: Deployment metadata: name: hive-deployment labels: app: hive spec: replicas: 3 # 设置副本数 selector: matchLabels: app: hive template: metadata: labels: app: hive spec: containers: - name: hive-server image: apache/hive:2.1.1 ports: - containerPort: 10000 env: - name: MYSQL_HOST value: mysql-service - name: MYSQL_PORT value: "3306" - name: MYSQL_USER valueFrom: secretKeyRef: name: mysql-secret key: username volumeMounts: - name: data-volume mountPath: /data # 数据卷 (persistentvolumeclaim.yaml) apiVersion: v1 kind: PersistentVolumeClaim metadata: name: hive-pvc labels: app: hive spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi # 请求的存储大小 # 数据卷定义 (pv.yaml) apiVersion: v1 kind: PersistentVolume metadata: name: hive-pv spec: capacity: storage: 5Gi accessModes: - ReadWriteOnce storageClassName: standard # 如果有特定的存储类别,填写这里 hostPath: path: /path/to/local/directory # 在宿主机上指定数据存放路径 # 服务 (service.yaml) apiVersion: v1 kind: Service metadata: name: hive-service labels: app: hive spec: selector: app: hive ports: - protocol: TCP port: 10000 targetPort: 10000 type: ClusterIP # 如果需要外网访问,可以改为NodePort或LoadBalancer # MySQL连接的Secret (mysql-secret.yaml) apiVersion: v1 kind: Secret metadata: name: mysql-secret type: Opaque data: username: cGFzc3dvcmQ= password: YWRtaW4= ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值