結果

問題 No.628 Tagの勢い
ユーザー pengin_2000pengin_2000
提出日時 2020-02-21 01:05:20
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 30,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 06:38:30
合計ジャッジ時間 830 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j, k;
	int no;
	int m, s;
	char t[32];
	char tag[10004][32];
	int a[10004], l = 0;
	int p;
	for (i = 0; i < n; i++)
	{
		scanf("%d%d%d", &no, &m, &s);
		for (j = 0; j < m; j++)
		{
			scanf("%s", t);
			p = -1;
			for (k = 0; k < l; k++)
			{
				if (strcmp(t, tag[k]) == 0)
				{
					p = k;
					break;
				}
			}
			if (p < 0)
			{
				p = l;
				strcpy(tag[l], t);
				a[l] = 0;
				l++;
			}
			a[p] += s;
		}
	}
	for (i = 0; i < 10; i++)
	{
		p = 0;
		for (j = 0; j < l; j++)
		{
			if (a[p] < a[j])
				p = j;
			else if (a[j] == a[p])
			{
				if (strcmp(tag[p], tag[j]) > 0)
					p = j;
			}
		}
		if (a[p] == 0)
			break;
		printf("%s %d\n", tag[p], a[p]);
		a[p] = 0;
	}
	return 0;
}
0