結果

問題 No.437 cwwゲーム
ユーザー willowoooowillowoooo
提出日時 2016-11-05 16:41:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 966 bytes
コンパイル時間 4,106 ms
コンパイル使用メモリ 79,220 KB
実行使用メモリ 46,524 KB
最終ジャッジ日時 2024-04-20 13:13:37
合計ジャッジ時間 12,014 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
41,172 KB
testcase_01 AC 134 ms
41,204 KB
testcase_02 AC 145 ms
41,340 KB
testcase_03 AC 137 ms
41,164 KB
testcase_04 AC 137 ms
41,004 KB
testcase_05 AC 137 ms
40,920 KB
testcase_06 AC 150 ms
41,376 KB
testcase_07 AC 185 ms
46,144 KB
testcase_08 AC 169 ms
43,232 KB
testcase_09 AC 182 ms
45,932 KB
testcase_10 AC 177 ms
45,036 KB
testcase_11 AC 140 ms
41,500 KB
testcase_12 AC 143 ms
41,744 KB
testcase_13 AC 150 ms
41,464 KB
testcase_14 AC 153 ms
41,652 KB
testcase_15 AC 189 ms
46,524 KB
testcase_16 AC 144 ms
41,228 KB
testcase_17 AC 142 ms
41,236 KB
testcase_18 AC 146 ms
41,396 KB
testcase_19 AC 136 ms
40,984 KB
testcase_20 AC 136 ms
41,612 KB
testcase_21 AC 139 ms
41,824 KB
testcase_22 AC 139 ms
41,068 KB
testcase_23 AC 141 ms
41,020 KB
testcase_24 AC 138 ms
41,072 KB
testcase_25 AC 141 ms
41,388 KB
testcase_26 AC 142 ms
41,312 KB
testcase_27 AC 136 ms
41,188 KB
testcase_28 AC 141 ms
41,272 KB
testcase_29 AC 138 ms
40,892 KB
testcase_30 AC 133 ms
41,304 KB
testcase_31 AC 137 ms
40,924 KB
testcase_32 AC 136 ms
41,260 KB
testcase_33 AC 151 ms
41,276 KB
testcase_34 AC 135 ms
41,320 KB
testcase_35 AC 143 ms
41,208 KB
testcase_36 AC 141 ms
41,664 KB
testcase_37 AC 138 ms
41,168 KB
testcase_38 AC 136 ms
41,420 KB
testcase_39 AC 137 ms
41,392 KB
testcase_40 AC 138 ms
41,228 KB
testcase_41 AC 144 ms
41,404 KB
testcase_42 AC 142 ms
41,184 KB
testcase_43 AC 145 ms
41,212 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