题目1324:The Best Rank

#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
struct grade{
    char stuID[7];
    int  cScore;
    int  mScore;
    int  eScore;
    double  aScore;
    int rank;
    int temprank;
    char course;
};

grade g[2000];

bool cmpBycSore(grade a,grade b){
     return a.cScore > b.cScore;
}
bool cmpBymSore(grade a,grade b){
    return a.mScore > b.mScore;
}
bool cmpByeSore(grade a,grade b){
    return a.eScore > b.eScore;
}
bool cmpByaSore(grade a,grade b){
    return a.aScore > b.aScore;
}

int main(){
    int m,n;
    while(cin >> n >> m){
        for(int i = 0 ; i < n ; i++){
            cin >> g[i].stuID >> g[i].cScore >> g[i].mScore >> g[i].eScore;
            g[i].aScore =  (g[i].cScore + g[i].mScore + g[i].eScore)/3;
            }
        
        sort(g,g + n,cmpByaSore);
        g[0].rank = 1;
        g[0].course = 'A';
        for(int i = 1 ; i < n ; i++){
            if(g[i].aScore == g[i-1].aScore)
                g[i].rank = g[i-1].rank;
            else
                g[i].rank = i + 1;
            g[i].course = 'A';
        }

        sort(g,g + n,cmpBycSore);
        g[0].temprank = 1;
        for(int i = 1 ; i < n ; i++){
            if(g[i].cScore == g[i-1].cScore)
                g[i].temprank = g[i-1].temprank;
            else
                g[i].temprank = i + 1;
        }
        for(int i = 0 ; i < n ; i++){
            if(g[i].temprank < g[i].rank){
                g[i].rank = g[i].temprank;
                g[i].course = 'C';
            }
        }
    
        sort(g,g + n,cmpBymSore);
        g[0].temprank = 1;
        for(int i = 1 ; i < n ; i++){
            if(g[i].mScore == g[i-1].mScore)
                g[i].temprank = g[i-1].temprank;
            else
                g[i].temprank = i + 1;
        }
        for(int i = 0 ; i < n ; i++){
            if(g[i].temprank < g[i].rank){
                g[i].rank = g[i].temprank;
                g[i].course = 'M';
            }
        }

        sort(g,g + n,cmpByeSore);
        g[0].temprank = 1;
        for(int i = 1 ; i < n ; i++){
            if(g[i].eScore == g[i-1].eScore)
                g[i].temprank = g[i-1].temprank;
            else
                g[i].temprank = i + 1;
        }
        for(int i = 0 ; i < n ; i++){
            if(g[i].temprank < g[i].rank){
                g[i].rank = g[i].temprank;
                g[i].course = 'E';
            }
        }
        char query[7];
        int i,j;
        for(i = 0;i < m;i++){
            cin >> query;
            for(j = 0;j < n;j++)
                if(!strcmp(query,g[j].stuID))
                    break;
            if(j < n)        
                 cout << g[j].rank << " " << g[j].course << endl;
            else
                 cout << "N/A" << endl;        
        }    
    }
    return 1;
}


世界顶级艺术品展会,推出A/B/C三种参观票,分别对应参观时间6/4/2小时。展会设有E1、E2、E3三个排队安检入口,对应的安检时间分别为1、2、5分钟/人。每天的参观人数上限为1500人,展馆工作时间8:00-23:30。 假设:使用过排队查询的用户,都会遵从系统推荐。 输入格式: 第1行:已进入的参观者的数量、E1~E3入口处当前排队人数、当前时间、查询排队推荐的用户数量n(查询用户尚未排队)。 比如:输入“1327 100 48 19 1215 8”,表示已进入1327人,E1口100人排队,E2口48人排队,E3口19人排队,当前时间为12点15分,8名用户正在查询排队推荐。 第2行:输入n个用户的票类别。 输出格式: 依次输出对应用户的提示信息,包括: 推荐可以最早进入展馆的入口,预计等待时间(若等待时间一致,按E1->E2->E3优先顺序推荐入口); 若闭馆前参观时间不足(A票<6小时,B票<4小时,C票<2小时),提示“visit time is insufficient!”,用户将放弃当天参观; 若(已进入人数+排队人数)>=1500,不再检票,提示“the number of users has reached the upper limit!”,禁止参观者进入; 若当前时间不在8:00-23:30范围内,输出“Out of service!”;若参观票类型错误,输出“Ticket error!”。 输入样例1: 1327 100 48 19 1215 8 CCCBBBAA 输出样例1: User 1: the best entrance is E2, expected waiting time is 1:38. User 2: the best entrance is E2, expected waiting time is 1:40. User 3: the best entrance is E3, expected waiting time is 1:40. User 4: the best entrance is E1, expected waiting time is 1:41. User 5: the best entrance is E1, expected waiting time is 1:42. User 6: the best entrance is E2, expected waiting time is 1:42. User 7: the number of users has reached the upper limit! User 8: the number of users has reached the upper limit! 输入样例2: 1000 100 48 19 1715 8 CCCBBBAA 输出样例2: User 1: the best entrance is E2, expected waiting time is 1:38. User 2: the best entrance is E2, expected waiting time is 1:40. User 3: the best entrance is E3, expected waiting time is 1:40. User 4: the best entrance is E1, expected waiting time is 1:41. User 5: the best entrance is E1, expected waiting time is 1:42. User 6: the best entrance is E2, expected waiting time is 1:42. User 7: visit time is insufficient! User 8: visit time is insufficient! 输入样例3: 0 0 0 0 759 8 输出样例3: Out of service! 输入样例4: 0 0 0 0 800 5 ABCDA 输出样例4: User 1: the best entrance is E1, expected waiting time is 0:01. User 2: the best entrance is E1, expected waiting time is 0:02. User 3: the best entrance is E2, expected waiting time is 0:02. User 4: Ticket error! User 5: the best entrance is E1, expected waiting time is 0:03. 代码长度限制 16 KB 时间限制 400 ms 内存限制 64 MB 栈限制 8192 KB C (gcc) 1 2 #include <stdio.h>
最新发布
11-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值