結果

問題 No.628 Tagの勢い
ユーザー MisterMister
提出日時 2020-04-09 16:57:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 2,545 ms
コンパイル使用メモリ 101,108 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 14:47:53
合計ジャッジ時間 2,618 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>

void solve() {
    int n;
    std::cin >> n;

    std::map<std::string, int> score;
    while (n--) {
        int m, x;
        std::cin >> m >> m >> x;

        while (m--) {
            std::string s;
            std::cin >> s;

            if (!score.count(s)) score[s] = 0;
            score[s] += x;
        }
    }

    std::vector<std::pair<int, std::string>> ps;
    for (auto& p : score) {
        ps.emplace_back(-p.second, p.first);
    }

    std::sort(ps.begin(), ps.end());
    if (ps.size() > 10) ps.resize(10);

    for (auto p : ps) {
        std::cout << p.second << " " << -p.first << std::endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0