結果
問題 |
No.628 Tagの勢い
|
ユーザー |
![]() |
提出日時 | 2018-03-04 13:28:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 880 bytes |
コンパイル時間 | 4,750 ms |
コンパイル使用メモリ | 185,616 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-07 22:35:40 |
合計ジャッジ時間 | 2,698 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; template <typename T> T gcd(T x, T y) { if (y == 0) return x; return gcd(y, x % y); } template <typename T> T lcm(T x, T y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; } int main() { int N; cin >> N; map<string, int> mp; for (int i = 0; i < N; i++) { int No; cin >> No; int M, S; cin >> M >> S; for (int j = 0; j < M; j++) { string tag; cin >> tag; mp[tag] += S; } } vector<vector<string>> v(10001); for (auto m : mp) { v[m.second].push_back(m.first); } int cnt = 0; for (int i = 10000; i >= 0; i--) { sort(v[i].begin(), v[i].end()); int size = v[i].size(); for (int j = 0; j < size; j++) { if (cnt == 10) { i = -1; break; } cout << v[i][j] << ' ' << i << endl; cnt++; } } }