結果
| 問題 |
No.161 制限ジャンケン
|
| コンテスト | |
| ユーザー |
jp_ste
|
| 提出日時 | 2015-03-16 07:59:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 1,896 ms |
| コンパイル使用メモリ | 77,604 KB |
| 実行使用メモリ | 56,300 KB |
| 最終ジャッジ日時 | 2024-06-28 23:06:09 |
| 合計ジャッジ時間 | 4,781 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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