結果
問題 | No.161 制限ジャンケン |
ユーザー | ぴろず |
提出日時 | 2015-03-05 23:48:18 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 137 ms / 5,000 ms |
コード長 | 1,176 bytes |
コンパイル時間 | 2,197 ms |
コンパイル使用メモリ | 73,504 KB |
実行使用メモリ | 57,708 KB |
最終ジャッジ日時 | 2023-08-20 04:22:17 |
合計ジャッジ時間 | 5,095 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,360 KB |
testcase_01 | AC | 115 ms
55,180 KB |
testcase_02 | AC | 112 ms
55,408 KB |
testcase_03 | AC | 115 ms
55,412 KB |
testcase_04 | AC | 115 ms
55,648 KB |
testcase_05 | AC | 115 ms
57,356 KB |
testcase_06 | AC | 116 ms
56,040 KB |
testcase_07 | AC | 116 ms
55,552 KB |
testcase_08 | AC | 134 ms
55,664 KB |
testcase_09 | AC | 113 ms
55,532 KB |
testcase_10 | AC | 121 ms
55,924 KB |
testcase_11 | AC | 120 ms
55,348 KB |
testcase_12 | AC | 118 ms
55,432 KB |
testcase_13 | AC | 137 ms
57,708 KB |
testcase_14 | AC | 117 ms
55,708 KB |
testcase_15 | AC | 135 ms
55,756 KB |
testcase_16 | AC | 116 ms
55,744 KB |
testcase_17 | AC | 119 ms
55,548 KB |
testcase_18 | AC | 120 ms
55,712 KB |
ソースコード
package no161; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int gx = sc.nextInt(); int cx = sc.nextInt(); int px = sc.nextInt(); int gy = 0, cy = 0, py = 0; char[] s = sc.next().toCharArray(); int n = s.length; for(int i=0;i<n;i++) { if (s[i] == 'G') { gy++; }else if(s[i] == 'C') { cy++; }else{ py++; } } int max = 0; for(int gg=0;gg<=300;gg++) { if (gg > gx || gg > gy) { break; } for(int gc=0;gc<=300;gc++) { if (gg+gc > gx || gc > cy) { break; } for(int cg=0;cg<=300;cg++) { if (gg+cg > gy || cg > cx) { break; } int gp = gx - gg - gc; int pg = gy - gg - cg; if (gp > py || pg > px) { continue; } int cp = Math.min(cx - cg, py - gp); int cc = cx - cg - cp; int pp = py - gp - cp; // System.out.println("---"); // System.out.println(gg + " " + gc + " " + gp + "\n" + cg + " " + cc + " " + cp + "\n" + pg + " " + (px - pg - pp) + " " + pp); max = Math.max(max, (gc + cp + pg) * 3 + gg + cc + pp); } } } System.out.println(max); } }