結果
問題 |
No.628 Tagの勢い
|
ユーザー |
![]() |
提出日時 | 2020-04-03 15:57:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 2,412 ms |
コンパイル使用メモリ | 188,648 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 00:50:27 |
合計ジャッジ時間 | 3,277 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct tag { int p; string t; tag() {} tag(int p_, string t_): p(p_), t(t_) {} bool operator<(const tag& rh) const { if (rh.p == p) { return t > rh.t; } return p < rh.p; } }; int main() { int n; cin >> n; map<string, int> mp; for (int i = 0; i < n; ++i) { int id; cin >> id; int m, p; cin >> m >> p; for (int j = 0; j < m; ++j) { string s; cin >> s; mp[s] += p; } } vector<tag> tags; for (auto const &e: mp) { tags.emplace_back(e.second, e.first); } sort(tags.rbegin(), tags.rend()); int cnt = 0; for (tag const &tg: tags) { if (cnt == 10) break; cout << tg.t << " " << tg.p << '\n'; cnt++; } return 0; }