[辽宁省程序设计竞赛]A 组队分配

A-组队分配_2020 年第一届辽宁省大学生程序设计竞赛 (nowcoder.com)icon-default.png?t=L892https://ac.nowcoder.com/acm/contest/8440/A

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

typedef pair<int,string> PII;

int main()
{
    int t, n;
    string x;
    int rank;
    cin >> t;
    
    while(t --)
    {
        vector<PII> v;
        cin >> n;
        int n2 = 3*n;
        for(int i = 0; i < n2; i++){
            cin >> x >> rank;
            v.push_back({rank, x});
        }
        sort(v.begin(), v.end());
        
        for(int i = 0; i < n2; i+=3)
        {
            cout<<"ACM-"<<i/3<<' '<<v[i+2].second<<' '<<v[i+1].second<<' '<< v[i].second;
            cout << endl;
        }

    }
    return 0;
}

posted @ 2021-10-11 20:20  泥烟  阅读(23)  评论(0编辑  收藏  举报