結果
問題 | No.161 制限ジャンケン |
ユーザー | tsunabit |
提出日時 | 2020-03-09 00:29:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 123 ms / 5,000 ms |
コード長 | 1,087 bytes |
コンパイル時間 | 3,023 ms |
コンパイル使用メモリ | 77,128 KB |
実行使用メモリ | 41,712 KB |
最終ジャッジ日時 | 2024-04-25 09:44:55 |
合計ジャッジ時間 | 5,922 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
41,384 KB |
testcase_01 | AC | 100 ms
40,372 KB |
testcase_02 | AC | 106 ms
40,296 KB |
testcase_03 | AC | 111 ms
41,084 KB |
testcase_04 | AC | 108 ms
40,020 KB |
testcase_05 | AC | 110 ms
40,916 KB |
testcase_06 | AC | 115 ms
41,388 KB |
testcase_07 | AC | 108 ms
40,612 KB |
testcase_08 | AC | 112 ms
41,088 KB |
testcase_09 | AC | 116 ms
41,020 KB |
testcase_10 | AC | 115 ms
41,448 KB |
testcase_11 | AC | 110 ms
41,044 KB |
testcase_12 | AC | 117 ms
41,292 KB |
testcase_13 | AC | 115 ms
41,216 KB |
testcase_14 | AC | 116 ms
41,712 KB |
testcase_15 | AC | 114 ms
41,428 KB |
testcase_16 | AC | 112 ms
41,268 KB |
testcase_17 | AC | 115 ms
41,256 KB |
testcase_18 | AC | 123 ms
41,444 KB |
ソースコード
import java.util.*; import java.io.*; import java.math.*; public class No161 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] gcp = {sc.nextInt(), sc.nextInt(), sc.nextInt()}; String[] s = sc.next().split(""); int ans = 0; ans += jan(gcp, 0, "C", s, 3); ans += jan(gcp, 1, "P", s, 3); ans += jan(gcp, 2, "G", s, 3); ans += jan(gcp, 0, "G", s, 1); ans += jan(gcp, 1, "C", s, 1); ans += jan(gcp, 2, "P", s, 1); System.out.println(ans); } public static int jan(int[] gcp, int y, String c, String[] s, int p) { int a = 0; int t = kaz(c, s); if(gcp[y] >= t) { gcp[y] -= t; a += t * p; del(c, s, t); }else { del(c, s, gcp[y]); a += gcp[y] * p; gcp[y] = 0; } return a; } public static int kaz(String c, String[] s) { int t = 0; for(int i = 0; i < s.length; i++) { if(c.equals(s[i])) t++; } return t; } public static void del(String c, String[] s, int k) { for(int i = 0; i < s.length; i++) { if(k == 0) return; if(c.equals(s[i])) { k--; s[i] = "Z"; } } } }