Applications(ZOJ3705)

题目链接:http://icpc.moe/onlinejudge/showProblem.do?problemCode=3705

很长的一道模拟题,其实题目很简单

题目大意如下:现在一个HR需要从这么多的application里边选出m个最优秀的人。然后给定一系列的规则。

1.刷题量,mao_mao库的一题2.5分,old库的一题1.5分,题号如果是素数一题1分,其余的按0.3分算

2.校赛,自己所在的队伍123名分别加分36,27,18分

3.其他网站的比赛排名。取第三高的运算max(0, (r - 1200) / 100) * 1.5加分。

4.女生+33

然后会给定题库。然后题目就很简单了。其实我第一次就写对了,但是最终输出的时候忘记了m,死盯着样例,然后最终的循环只输出前三个。然后错了大概十几次,然后终于发现了,顿时无语。

模拟题有时候就是这样,很长,变量很多,有很多需要控制,一定要看清楚

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
int t,n,m;

set<int> mao_mao,old_Surgeon_contest;//就算有前导0也是int型,所以这里就不要用string了
int mao_maonum,old_Surgeon_contestnum;

int Q;
map<string , int> competition;//存的校赛信息

struct application
{
    string name,teamname,sex;//姓名,队名,性别

    int pro_num,take_game_num;//题目数,比赛数

    double points;//分数

    vector<double> gamerace;

} people[505];

double judgecompetition(string teamname) //校赛判断
{
    if(competition[teamname]==1)
        return 36;
    if(competition[teamname]==2)
        return 27;
    if(competition[teamname]==3)
        return 18;
    return 0;
}
bool judge_prim(int x)//素数
{
    for(int i=2; i*i<=x; i++)
        if(x%i==0)
            return 0;
    return 1;
}


double judge(int pro_id)//判断题目分数
{
    if(mao_mao.find(pro_id)!=mao_mao.end())
        return 2.5;
    if(old_Surgeon_contest.find(pro_id)!=old_Surgeon_contest.end())
        return 1.5;
    if(judge_prim(pro_id))
        return 1.0;
    return 0.3;
}

bool cmp(application x,application y)//最终排名
{
    return x.points>y.points;
}

int main()
{
    cin>>t;
    while(t--)
    {
        cin>>n>>m;

        mao_mao.clear();//mao_mao题库清空
        cin>>mao_maonum;
        for(int i=0; i<mao_maonum; i++)//mao_mao题库
        {
            int temp;
            cin>>temp;
            mao_mao.insert(temp);
        }

        old_Surgeon_contest.clear();//old_Surgeon_contest题库清空
        cin>>old_Surgeon_contestnum;
        for(int i=0; i<old_Surgeon_contestnum; i++)//old_Surgeon_contest题库
        {
            int temp;
            cin>>temp;
            old_Surgeon_contest.insert(temp);
        }

        competition.clear();//校赛信息清空
        cin>>Q;
        for(int i=0; i<Q; i++)//校赛信息
        {
            string s;
            int itrank;
            cin>>s>>itrank;
            competition[s]=itrank;
        }

        for(int i=0; i<n; i++)//n个人的姓名,队伍,性别,刷题,比赛
        {
            people[i].gamerace.clear();//清空排名
            people[i].points=0;//初始化

            cin>>people[i].name>>people[i].teamname>>people[i].sex;//姓名,队伍,性别

            if(people[i].sex=="F")//性别判断
                people[i].points+=33;

            people[i].points+=judgecompetition(people[i].teamname);//校赛判断

            cin>>people[i].pro_num>>people[i].take_game_num;//题目,比赛

            for(int j=0; j<people[i].pro_num; j++)//题目加分
            {
                int temp;
                cin>>temp;
                people[i].points+=judge(temp);
            }

            for(int j=0; j<people[i].take_game_num; j++)//其他网站比赛排名
            {
                double temp;
                cin>>temp;
                people[i].gamerace.push_back(temp);
            }
            if(people[i].take_game_num>=3)//大于等于3进行排名加分
            {
                sort(people[i].gamerace.begin(),people[i].gamerace.end(),greater<double>());
                people[i].points+=max(0.0,( people[i].gamerace[2]- 1200)*1.0/ 100) * 1.5 ;
            }
        }
        
        sort(people,people+n,cmp);//最终

        for(int i=0; i<m; i++)//是m!!!!自己太粗心了
        {
            cout<<people[i].name<<" ";
            printf("%.3f\n",people[i].points);
        }
    }
    return 0;
}



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值