結果
問題 |
No.349 干支の置き物
|
ユーザー |
![]() |
提出日時 | 2025-03-25 15:11:00 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 488 ms |
コンパイル使用メモリ | 26,368 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-03-25 15:11:02 |
合計ジャッジ時間 | 1,734 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:7:52: warning: excess elements in array initializer 7 | int etoList[12] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; | ^ main.c:7:52: note: (near initialization for ‘etoList’) main.c:10:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&n); | ^~~~~~~~~~~~~~ main.c:12:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%s",str); | ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #include <stdbool.h> void main(void){ const char eto[12][10] = {"ne","ushi","tora","u","tatsu","mi","uma","hitsuji","saru","tori","inu","i"}; int etoList[12] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; char str[100] = "a"; int n = 0; scanf("%d",&n); for(int i = 0 ; i < n ;i++){ scanf("%s",str); for(int j = 0 ; j < 12 ; j++){ if(strcmp(eto[j],str) == 0){ etoList[j]++; break; } } } bool orderFlg = true; for(int i = 0 ; i < 12 ;i++){ if(n%2 == 0 && n/2 < etoList[i] || n%2 != 0 && n/2+1 < etoList[i]){ orderFlg = false; } } if(orderFlg){ printf("YES"); }else{ printf("NO"); } }