ZOJ 3705 10th 省赛 A Applications【模拟】

11 篇文章 0 订阅
9 篇文章 0 订阅

题目链接

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3705

思路

算是比较简单的模拟题吧,题意太长就不讲了。
比赛时是最后的时间做这题的,结果看太快了没看到分数相同时要按名字字母顺序排,导致WA到最后。
后来debug时想着按分数增序然后输出后m个,结果比较名字时写的还是小于导致名字成增序,逆着输出就是降序了,于是又debug了好久。果然细心好重要。

AC代码

#include <bits/stdc++.h>
using namespace std;

int prm[100000];
const int MAXV = 10000;
bool isPrime[MAXV+1];
int size=0;
void getPrime()  
{
    memset(isPrime, true, sizeof(isPrime));
    int sq = sqrt((double)MAXV) + 1;
    int i,j,k;
    for(i = 2;i <= sq; i++)
        if(isPrime[i])
            for(j = 2,k = MAXV/i+1;j < k;j++)
                isPrime[i*j] = false;
    for( i = 2 ; i <= MAXV; i++)
        if(isPrime[i])
            prm[size++] = i;
    isPrime[0] = isPrime[1] = false;
}


map<int,double>problem;
map<string,double>contest;

struct node
{
    string name;
    double score;
}
app[600];

bool cmp(node a, node b)
{
    if(fabs(a.score-b.score)<1e-6)
        return a.name<b.name;
    return a.score>b.score;
}
int main()
{
    getPrime();
    int T;
    cin>>T;
    while(T--)
    {
        problem.clear();
        contest.clear();
        int n,m;
        cin>>n>>m;
        int r,s;
        cin>>r;
        for(int i=0 ; i<r ; ++i)
        {
            int t;
            cin>>t;
            problem[t]=2.5;
        }
        cin>>s;
        for(int i=0 ; i<s ; ++i)
        {
            int t;
            cin>>t;
            if(!problem.count(t))
                problem[t]=1.5;
        }
        int q;
        cin>>q;
        for(int i=0 ; i<q ; ++i)
        {
            string name;
            int num;
            cin>>name>>num;
            int score=0;
            if(num==1)score=36;
            else if(num==2)score=27;
            else if(num==3)score=18;
            if(score)contest[name]=score;
        }
        for(int i=0 ; i<n ; ++i)
        {
            string name1,name2,sex;
            int p,c;
            cin>>name1>>name2>>sex>>p>>c;
            app[i].name=name1;
            app[i].score=0;
            if(contest.count(name2))
                app[i].score+=contest[name2];
            if(sex=="F")app[i].score+=33;
            for(int j=0 ; j<p ; ++j)
            {
                int id;
                cin>>id;
                if(problem.count(id))app[i].score+=problem[id];
                else if(isPrime[id])app[i].score+=1;
                else app[i].score+=0.3;
            }
            int rating[2000]={0};
            for(int j=0 ; j<c ; ++j)
            {
                cin>>rating[j];
            }
            sort(rating,rating+c);
            if(c>=3)
                app[i].score+=max(0.0,(rating[c-3]-1200.0)/100*1.5);
        }
        sort(app,app+n,cmp);
        for(int i=0 ; i<m ; ++i)
        {
            cout<<app[i].name<<" ";
            cout<<fixed<<setprecision(3);
            cout<<app[i].score<<"\n";
        }
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值