結果

問題 No.628 Tagの勢い
ユーザー yukileo9yukileo9
提出日時 2021-07-11 17:31:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,075 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 186,696 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 20:15:36
合計ジャッジ時間 3,300 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

void tag_628(void) {
    int n;
    cin >> n;
    map<string, int> tag;
    int no, m, s;
    string tags;
    for (int i = 0; i < n; i++) {
        cin >> no;
        cin >> m >> s;
        for (int j = 0; j < m; j++) {
            cin >> tags;
            tag[tags] += s;
        }
    }

    map<string, int>::iterator tag_ptr;
    map<int, vector<string>> ans;
    for (tag_ptr = tag.begin(); tag_ptr != tag.end(); tag_ptr++) {
        ans[(-1) * tag_ptr->second].push_back(tag_ptr->first);
    }

    map<int, vector<string>>::iterator ansptr;
    int cnt = 0;
    for (ansptr = ans.begin(); ansptr != ans.end(); ansptr++) {
        if ((int)ansptr->second.size() > 1)
            sort(ansptr->second.begin(), ansptr->second.end());
        for (int j = 0; j < (int)ansptr->second.size(); j++) {
            cout << ansptr->second[j] << " " << ansptr->first * (-1) << endl;
            cnt++;
            if (cnt == 10) break;
        }
        if (cnt == 10) break;
    }
}

int main(void) {
    tag_628();
    return 0;
}
0