zoukankan      html  css  js  c++  java
  • 1141 PAT Ranking of Institutions (25 分)

    水~。

    const int N=1e5+10;
    struct Node
    {
        int scoreb,scorea,scoret;
        int score;
        int cnt;
        int rank;
        string school;
        bool operator<(const Node &W) const
        {
            if(score != W.score) return score > W.score;
            if(cnt != W.cnt) return cnt < W.cnt;
            return school < W.school;
        }
    };
    map<string,Node> mp;
    int n;
    
    string trans(string s)
    {
        for(int i=0;i<s.size();i++)
            s[i]=tolower(s[i]);
        return s;
    }
    
    int main()
    {
        cin>>n;
    
        for(int i=0;i<n;i++)
        {
            string id,school;
            int score;
            cin>>id>>score>>school;
            school=trans(school);
            mp[school].school=school;
            if(id[0] == 'A')
                mp[school].scorea+=score;
            else if(id[0] == 'B')
                mp[school].scoreb+=score;
            else
                mp[school].scoret+=score;
            mp[school].cnt++;
        }
    
        vector<Node> res;
        for(auto t:mp)
        {
            t.se.score=t.se.scoreb/1.5+t.se.scorea+t.se.scoret*1.5;
            res.pb(t.se);
        }
    
        sort(res.begin(),res.end());
        cout<<res.size()<<endl;
        for(int i=0;i<res.size();i++)
        {
            if(i && res[i].score == res[i-1].score)
                res[i].rank=res[i-1].rank;
            else
                res[i].rank=i+1;
            cout<<res[i].rank<<' '<<res[i].school<<' '<<res[i].score<<' '<<res[i].cnt<<endl;
        }
    
        //system("pause");
        return 0;
    }
    
  • 相关阅读:
    JetBrains 里不为人知的秘密(2)--快捷键篇
    phpstorm 2017之输入法
    JetBrains 里不为人知的秘密
    Windows Server 2012 远程连接
    visibility和display的区别
    【dp】摘花生
    【dp】 背包问题
    【dp】求最长公共子序列
    【dp】合唱队形
    【dp】友好城市
  • 原文地址:https://www.cnblogs.com/fxh0707/p/14481155.html
Copyright © 2011-2022 走看看