結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
![]() |
提出日時 | 2015-03-09 19:27:50 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 727 bytes |
コンパイル時間 | 2,157 ms |
コンパイル使用メモリ | 74,584 KB |
実行使用メモリ | 54,396 KB |
最終ジャッジ日時 | 2024-06-24 16:56:13 |
合計ジャッジ時間 | 5,608 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 9 |
ソースコード
import java.beans.IntrospectionException; import java.util.*; 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 te = sc.next(); int ans =0 ; for(int i=0;i<te.length();i++){ if(te.charAt(i)=='G'){ if(p>0){ p--; ans+=3; }else if(g>0){ g--; ans+=1; }else{ c--; } }else if(te.charAt(i)=='C'){ if(g>0){ g--; ans+=3; }else if(c>0){ c--; ans+=1; }else{ p--; } }else{ if(c>0){ c--; ans+=3; }else if(p>0){ p--; ans+=1; }else{ g--; } } } System.out.println(ans); } }