結果

問題 No.628 Tagの勢い
ユーザー kichirb3
提出日時 2018-03-02 11:49:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 874 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 101,516 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 22:37:02
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.628 Tagの勢い
// https://yukicoder.me/problems/no/628
//
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <unordered_map>
using namespace std;


int main() {
    int N;
    cin >> N;

    unordered_map<string, int> scores;
    for (auto i = 0; i < N; ++i) {
        int dummy;
        cin >> dummy;
        int M, S;
        cin >> M >> S;
        for (auto j = 0; j < M; j++) {
            string t;
            cin >> t;
            scores[t] += S;
        }
    }

    vector<pair<int, string>> res;
    for (auto s: scores) {
        res.push_back(make_pair(-s.second, s.first));
    }
    sort(res.begin(), res.end());

    int count = 0;
    for (auto r: res) {
        cout << r.second << " " << -r.first << endl;
        ++count;
        if (count >= 10)
            break;
    }
}
0