結果

問題 No.437 cwwゲーム
ユーザー willowoooowillowoooo
提出日時 2016-11-05 16:41:36
言語 Java19
(openjdk 21)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 3,380 ms
コンパイル使用メモリ 75,308 KB
実行使用メモリ 60,584 KB
最終ジャッジ日時 2023-08-02 13:06:56
合計ジャッジ時間 10,415 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,580 KB
testcase_01 AC 119 ms
55,616 KB
testcase_02 AC 125 ms
55,512 KB
testcase_03 AC 117 ms
55,568 KB
testcase_04 AC 115 ms
56,052 KB
testcase_05 AC 117 ms
55,292 KB
testcase_06 AC 124 ms
55,488 KB
testcase_07 AC 158 ms
59,616 KB
testcase_08 AC 141 ms
57,896 KB
testcase_09 AC 163 ms
60,584 KB
testcase_10 AC 156 ms
60,292 KB
testcase_11 AC 114 ms
55,520 KB
testcase_12 AC 119 ms
55,948 KB
testcase_13 AC 125 ms
55,752 KB
testcase_14 AC 125 ms
55,456 KB
testcase_15 AC 164 ms
60,056 KB
testcase_16 AC 117 ms
55,784 KB
testcase_17 AC 120 ms
55,744 KB
testcase_18 AC 120 ms
55,280 KB
testcase_19 AC 118 ms
55,276 KB
testcase_20 AC 116 ms
55,216 KB
testcase_21 AC 119 ms
55,628 KB
testcase_22 AC 118 ms
55,400 KB
testcase_23 AC 118 ms
55,472 KB
testcase_24 AC 117 ms
55,468 KB
testcase_25 AC 117 ms
55,464 KB
testcase_26 AC 118 ms
55,680 KB
testcase_27 AC 115 ms
55,968 KB
testcase_28 AC 116 ms
55,480 KB
testcase_29 AC 113 ms
53,944 KB
testcase_30 AC 113 ms
55,712 KB
testcase_31 AC 115 ms
55,652 KB
testcase_32 AC 117 ms
55,512 KB
testcase_33 AC 122 ms
55,612 KB
testcase_34 AC 116 ms
53,708 KB
testcase_35 AC 118 ms
55,808 KB
testcase_36 AC 116 ms
55,604 KB
testcase_37 AC 116 ms
56,216 KB
testcase_38 AC 117 ms
56,028 KB
testcase_39 AC 119 ms
55,648 KB
testcase_40 AC 119 ms
55,508 KB
testcase_41 AC 119 ms
55,304 KB
testcase_42 AC 117 ms
55,448 KB
testcase_43 AC 117 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package test;

import java.util.Arrays;
import java.util.Scanner;

public class No437 {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		System.out.println(max(s));
	}

	int max(String s){
		char[] ss = s.toCharArray();
		int n = s.length();

		int max = 0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				 for (int k = j+1; k < n; k++) {
					if(ss[i] != '0' && ss[i] != ss[j] && ss[j] == ss[k]){
						StringBuilder sb = new StringBuilder();
						sb.append(ss[i]).append(ss[j]).append(ss[k]);
						int t = Integer.parseInt(sb.toString());
						StringBuilder sb2 = new StringBuilder(s);
						sb2.deleteCharAt(k);
						sb2.deleteCharAt(j);
						sb2.deleteCharAt(i);
						max = Math.max(max, t+max(sb2.toString()));

					}
				}

			}
		}
		return max;
	}




	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new No437().run();
	}
}
0