結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
MeloN
|
| 提出日時 | 2015-03-05 23:33:51 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,043 bytes |
| コンパイル時間 | 456 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 08:20:49 |
| 合計ジャッジ時間 | 1,118 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 9 |
コンパイルメッセージ
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 (G > 0) {
G--;
point++;
} else if (C > 0) {
C--;
}
} else if (S[i] == 'C') {
if (G > 0) {
G--;
point += 3;
} else if (C > 0) {
C--;
point++;
} else if (P > 0) {
P--;
}
} else if (S[i] == 'P') {
if (C > 0) {
C--;
point += 3;
} else if (P > 0) {
P--;
point++;
} else if (G > 0) {
G--;
}
}
}
printf("%d\n",point);
return (0);
}
MeloN