結果

問題 No.628 Tagの勢い
ユーザー kikagekikage
提出日時 2020-04-02 04:34:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 85,584 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-09 23:58:30
合計ジャッジ時間 3,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0