結果
| 問題 | No.161 制限ジャンケン |
| コンテスト | |
| ユーザー |
jp_ste
|
| 提出日時 | 2015-03-16 07:59:34 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| 記録 | |
| コンパイル時間 | 3,370 ms |
| コンパイル使用メモリ | 81,524 KB |
| 実行使用メモリ | 46,608 KB |
| 最終ジャッジ日時 | 2026-03-18 05:24:31 |
| 合計ジャッジ時間 | 5,140 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 9 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int G = sc.nextInt();
int C = sc.nextInt();
int P = sc.nextInt();
String S = sc.next();
int ans = 0;
for(int i=0; i<S.length(); i++) {
if(G==0 && C==0 && P==0) break;
char look = S.charAt(i);
if(look == 'G') {
if (P>0) { P--; ans+=3; }
else if(G>0) { G--; ans+=1; }
else if(C>0) { C--; }
} else if(look == 'C') {
if (G>0) { G--; ans+=3; }
else if(C>0) { C--; ans+=1; }
else if(P>0) { P--; }
} else if(look == 'P') {
if (C>0) { C--; ans+=3; }
else if(P>0) { P--; ans+=1; }
else if(G>0) { G--; }
}
}
System.out.println(ans);
}
}
jp_ste