結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-06 17:26:14 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,129 bytes |
コンパイル時間 | 600 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 04:27:56 |
合計ジャッジ時間 | 1,280 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
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 300int 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;S[i] = 0;}} else if (S[i] == 'C') {if (G > 0) {G--;point += 3;S[i] = 0;}} else if (S[i] == 'P') {if (C > 0) {C--;point += 3;S[i] = 0;}}}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);}