結果
問題 |
No.628 Tagの勢い
|
ユーザー |
![]() |
提出日時 | 2023-08-19 12:23:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 1,185 bytes |
コンパイル時間 | 1,529 ms |
コンパイル使用メモリ | 116,856 KB |
最終ジャッジ日時 | 2025-02-16 11:29:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<cctype> #include<set> #include<bitset> #include<math.h> #include<map> #include<queue> #include<iomanip> #include<vector> #include <utility> using namespace std; bool comp(pair<int, string> &a, pair<int, string> &b){ if (a.first != b.first) return a.first > b.first; else return a.second < b.second; } int main() { int n, num; cin >> n; vector<pair<int, string>> vec; for (int i = 0; i < n; i++){ int m, s; cin >> num >> m >>s; for (int j = 0; j < m; j++){ string tag; cin >> tag; int vs = vec.size(); for (int k = 0; k < vs; k++){ if (vec.at(k).second == tag){ vec.at(k).first += s; break; } if (k == vec.size() - 1) vec.push_back(make_pair(s, tag)); } if (vec.size() == 0) vec.push_back(make_pair(s, tag)); } } sort(vec.begin(), vec.end(), comp); num = 0; for (auto x : vec){ cout << x.second << " " << x.first << endl; num++; if (num == 10) break; } }