結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー くれちーくれちー
提出日時 2016-11-18 23:12:40
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,119 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 22,784 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 18:46:16
合計ジャッジ時間 1,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
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], cnt = 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 == 1) {
			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]));
	}

	int 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;
			}
		}
		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