結果

問題 No.628 Tagの勢い
ユーザー AQUA16573837AQUA16573837
提出日時 2018-04-05 00:14:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,047 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 84,316 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 20:11:01
合計ジャッジ時間 1,827 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 5 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 = 0;
	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].tag != scores[i].tag) {
			scores[++np].tag = scores[i].tag;
			scores[np].score = scores[i].score;
		} else {
			scores[np].score += scores[i].score;
		}
	}
	np++;
	sort(scores, scores + np, [](const Score& a, const Score& b) {
		return a.score > b.score;
	});

	for (int i = 0; i < min(10, np); i++)
		printf("%s %d\n", scores[i].tag.c_str(), scores[i].score);
}
0