結果
問題 |
No.161 制限ジャンケン
|
ユーザー |
![]() |
提出日時 | 2016-01-04 15:33:44 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 982 bytes |
コンパイル時間 | 2,108 ms |
コンパイル使用メモリ | 77,184 KB |
実行使用メモリ | 37,160 KB |
最終ジャッジ日時 | 2024-09-19 11:11:19 |
合計ジャッジ時間 | 4,030 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 9 |
ソースコード
import java.io.*; import java.util.*; import java.math.*; class Main { public static void out (Object o) { System.out.println(o); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = br.readLine().split(" "); int g = Integer.parseInt(line[0]); int c = Integer.parseInt(line[1]); int p = Integer.parseInt(line[2]); char[] h = br.readLine().toCharArray(); int ans = 0; for (int i = 0; i < h.length; i++) { if (h[i] == 'G') { if (p > 0) { p--; ans += 3; } else if (g > 0) { g--; ans++; } else { c--; } } else if (h[i] == 'C') { if (g > 0) { g--; ans += 3; } else if (c > 0) { c--; ans++; } else { p--; } } else { if (c > 0) { c--; ans += 3; } else if (p > 0) { p--; ans++; } else { g--; } } } out(ans); } }