結果
| 問題 | No.628 Tagの勢い | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-04-02 04:34:04 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 841 bytes | 
| コンパイル時間 | 964 ms | 
| コンパイル使用メモリ | 83,896 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 16:23:08 | 
| 合計ジャッジ時間 | 1,879 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
ソースコード
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using P = pair<int,string>;
bool cmp(P x,P y){
    if(x.first>y.first)return true;
    else if(x.first==y.first && x.second<y.second)return true;
    else return false;
}
int main(){
    int N,id=0;
    cin >> N;
    string tag;
    map<string,int> tags;
    for(int i=0,n,M,S;i<N;i++){
        cin >> n >> M >> S;
        for(int m=0;m<M;m++){
            cin >> tag;
            tags[tag]+=S;
        }
    }
    vector<P> ranking(tags.size());
    for(auto it=tags.begin();it!=tags.end();it++){
        ranking[id++]=make_pair((*it).second,(*it).first);
    }
    sort(ranking.begin(),ranking.end(),cmp);
    for(int i=0;i<10 && i<ranking.size();i++){
        cout << ranking[i].second << " " << ranking[i].first << endl;
    }
    return 0;
}
            
            
            
        