結果
問題 | No.161 制限ジャンケン |
ユーザー |
![]() |
提出日時 | 2015-03-16 08:32:26 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 175 ms / 5,000 ms |
コード長 | 971 bytes |
コンパイル時間 | 2,285 ms |
コンパイル使用メモリ | 79,304 KB |
実行使用メモリ | 47,268 KB |
最終ジャッジ日時 | 2024-11-30 04:31:12 |
合計ジャッジ時間 | 6,266 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
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; String nextS = ""; //勝てる手 for(int i=0; i<S.length(); i++) { char look = S.charAt(i); boolean find = false; if(look == 'G') { if(P>0) { P--; ans+=3; find=true; } } else if(look == 'C') { if(G>0) { G--; ans+=3; find=true; } } else if(look == 'P') { if(C>0) { C--; ans+=3; find=true; } } if(find==false) { nextS += look; } } S = nextS; //あいこの手 for(int i=0; i<S.length(); i++) { char look = S.charAt(i); if(look == 'G') { if(G>0) { G--; ans+=1; } } else if(look == 'C') { if(C>0) { C--; ans+=1; } } else if(look == 'P') { if(P>0) { P--; ans+=1; } } } System.out.println(ans); } }