結果

問題 No.628 Tagの勢い
ユーザー 👑 naipianaipia
提出日時 2018-05-31 23:03:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 1,832 ms
コンパイル使用メモリ 175,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:15:04
合計ジャッジ時間 2,367 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool compare(const pair<int,string>& a, const pair<int,string>& b){
    if(a.first!=b.first) return a.first < b.first;
    else return a.second > b.second;
}

int main(){
    int n,no,m,s;
    string in;
    map<string,int> mp;
    vector< pair<int,string> > vp;
    cin >> n;
    while(cin >> no >> m >> s){
        for(int i=0;i<m;i++){
            cin >> in;
            mp[in]+=s;
        }
    }
    for(map<string,int>::iterator iter=mp.begin();iter!=mp.end();iter++) vp.push_back(make_pair(iter->second,iter->first));
    sort(vp.begin(),vp.end(),compare);
    for(int i=vp.size()-1;i>=0;i--){
        cout << vp[i].second << ' ' << vp[i].first << endl;
        if(vp.size()-i==10) break;
    }

    return 0;
}
0