結果
問題 |
No.447 ゆきこーだーの雨と雪 (2)
|
ユーザー |
![]() |
提出日時 | 2016-11-19 00:04:55 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,334 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 09:00:22 |
合計ジャッジ時間 | 1,984 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 20 |
コンパイルメッセージ
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]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }