結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー くれちーくれちー
提出日時 2016-11-19 00:04:55
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,334 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 23,168 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-04 19:09:20
合計ジャッジ時間 1,863 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 5 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 7 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 6 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 11 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:30:49: warning: format not a string literal and no format arguments [-Wformat-security]
   30 |                         sprintf(name_[cnt], name[i]);
      |                                             ~~~~^~~
main.c:13:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:14:33: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         for (i = 0; i < n; i++) scanf("%d", &l[i]);
      |                                 ^~~~~~~~~~~~~~~~~~
main.c:15:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~
main.c:21:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |                 scanf("%s %c", name[i], &p[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>

int score(int star, int rank) {
	return 50 * star + 50 * star / (0.8 + 0.2 * rank);
}

int main() {
	int n, l[26], t;
	char name[4000][17], p[4000];
	int i, j;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &l[i]);
	scanf("%d", &t);

	char name_[4000][17];
	int ssum[4000], s[26][4000], r[4000], cnt = 0, cntr = 0, flag, q[26] = {}, no;

	for (i = 0; i < t; i++) {
		scanf("%s %c", name[i], &p[i]);
		flag = 1;
		for (j = 0; j < cnt; j++) {
			if (strcmp(name_[j], name[i]) == 0) {
				flag = 0;
				break;
			}
		}
		if (flag) {
			sprintf(name_[cnt], name[i]);
			cnt++;
		}

		for (j = 0; j < cnt; j++) {
			if (strcmp(name_[j], name[i]) == 0) {
				no = j;
				break;
			}
		}
		int tmp = p[i] - 'A';
		q[tmp]++;
		ssum[no] += (s[tmp][no] = score(l[tmp], q[tmp]));

		cntr = 0;
		for (j = 0; j < cnt; j++) {
			if (ssum[no] == ssum[j]) cntr++;
		}
		r[no] = cntr;
	}

	int minr, max;

	for (i = 0; i < cnt; i++) {
		no = 0;
		max = ssum[0];
		for (j = 0; j < cnt; j++) {
			if (ssum[j] > max) {
				max = ssum[j];
				no = j;
			}
		}
		minr = r[no];
		for (j = 0; j < cnt; j++) {
			if (ssum[j] == max && r[j] < minr) no = j;
		}
		printf("%d %s ", i + 1, name_[no]);
		for (j = 0; j < n; j++) printf("%d ", s[j][no]);
		printf("%d\n", ssum[no]);
		ssum[no] = -1;
	}

	return 0;
}
0