結果
問題 |
No.628 Tagの勢い
|
ユーザー |
![]() |
提出日時 | 2018-04-05 00:19:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 1,099 bytes |
コンパイル時間 | 1,301 ms |
コンパイル使用メモリ | 83,984 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-07 22:41:05 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
#include <stdio.h> #include <algorithm> #include <deque> #include <string> #include <iostream> using namespace std; using ll = long long; void solve(); int main() { solve(); #ifdef DBG while (true); #endif } class Score { public: string tag; int score; }; void solve() { int n, no, m, s, sp = 0, np = 1; Score scores[10000]; cin >> n; for (int i = 0; i < n; i++) { cin >> no >> m >> s; for (int j = 0; j < m; j++) { cin >> scores[sp].tag; scores[sp++].score = s; } } sort(scores, scores + sp, [](const Score& a, const Score& b) { if (a.tag != b.tag) return a.tag < b.tag; return a.score < b.score; }); for (int i = 1; i < sp; i++) { if (scores[np - 1].tag != scores[i].tag) { scores[np].tag = scores[i].tag; scores[np++].score = scores[i].score; } else { scores[np - 1].score += scores[i].score; } } sort(scores, scores + np, [](const Score& a, const Score& b) { if (a.score != b.score) return a.score > b.score; return a.tag < b.tag; }); for (int i = 0; i < min(10, np); i++) printf("%s %d\n", scores[i].tag.c_str(), scores[i].score); }