結果

問題 No.628 Tagの勢い
ユーザー AQUA16573837AQUA16573837
提出日時 2018-04-05 00:19:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 1,243 ms
コンパイル使用メモリ 85,144 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 20:11:29
合計ジャッジ時間 1,910 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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);
}
0