結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
![]() |
提出日時 | 2015-03-06 17:21:25 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,051 bytes |
コンパイル時間 | 328 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 09:55:15 |
合計ジャッジ時間 | 1,099 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 3 WA * 13 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:10:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d%d%d",&G,&C,&P); | ^~~~~~~~~~~~~~~~~~~~~~~~ main.c:11:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%s",S); | ^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <string.h> #define MAX 300 int main(void) { int point = 0, G,C,P,count,i; char S[MAX]; scanf("%d%d%d",&G,&C,&P); scanf("%s",S); count = G+C+P; for (i = 0; i < count; i++) { if (S[i] == 'G') { if (P > 0) { P--; point += 3; } } else if (S[i] == 'C') { if (G > 0) { G--; point += 3; } } else if (S[i] == 'P') { if (C > 0) { C--; point += 3; } } } for (i = 0; i < count; i++) { if (S[i] == 'G') { if (G > 0) { G--; point++; } } else if (S[i] == 'C') { if (C > 0) { C--; point++; } } else if (S[i] == 'P') { if (P > 0) { P--; point++; } } } printf("%d\n",point); return (0); }