結果

問題 No.437 cwwゲーム
ユーザー GrenacheGrenache
提出日時 2016-10-28 22:52:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 1,180 bytes
コンパイル時間 5,228 ms
コンパイル使用メモリ 75,292 KB
実行使用メモリ 60,644 KB
最終ジャッジ日時 2023-08-02 12:53:41
合計ジャッジ時間 12,243 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,544 KB
testcase_01 AC 118 ms
55,776 KB
testcase_02 AC 127 ms
55,904 KB
testcase_03 AC 119 ms
55,904 KB
testcase_04 AC 118 ms
55,584 KB
testcase_05 AC 119 ms
55,936 KB
testcase_06 AC 128 ms
55,984 KB
testcase_07 AC 164 ms
60,288 KB
testcase_08 AC 157 ms
58,016 KB
testcase_09 AC 174 ms
60,644 KB
testcase_10 AC 161 ms
60,576 KB
testcase_11 AC 117 ms
55,824 KB
testcase_12 AC 118 ms
55,960 KB
testcase_13 AC 126 ms
55,972 KB
testcase_14 AC 126 ms
55,812 KB
testcase_15 AC 166 ms
60,396 KB
testcase_16 AC 119 ms
55,724 KB
testcase_17 AC 124 ms
55,732 KB
testcase_18 AC 123 ms
55,724 KB
testcase_19 AC 118 ms
55,720 KB
testcase_20 AC 119 ms
56,028 KB
testcase_21 AC 120 ms
55,868 KB
testcase_22 AC 123 ms
55,712 KB
testcase_23 AC 121 ms
55,740 KB
testcase_24 AC 120 ms
55,576 KB
testcase_25 AC 121 ms
55,812 KB
testcase_26 AC 122 ms
55,616 KB
testcase_27 AC 117 ms
55,876 KB
testcase_28 AC 117 ms
56,184 KB
testcase_29 AC 116 ms
55,960 KB
testcase_30 AC 116 ms
55,692 KB
testcase_31 AC 116 ms
55,552 KB
testcase_32 AC 117 ms
55,812 KB
testcase_33 AC 124 ms
55,808 KB
testcase_34 AC 117 ms
55,868 KB
testcase_35 AC 112 ms
55,684 KB
testcase_36 AC 116 ms
55,732 KB
testcase_37 AC 118 ms
55,924 KB
testcase_38 AC 117 ms
55,912 KB
testcase_39 AC 117 ms
55,352 KB
testcase_40 AC 117 ms
56,196 KB
testcase_41 AC 120 ms
55,696 KB
testcase_42 AC 120 ms
55,632 KB
testcase_43 AC 120 ms
55,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder437_1 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		String s = sc.next();

		pr.println(max(s));
	}

	private static 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 tmp = new StringBuilder();
						tmp.append(ss[i]).append(ss[j]).append(ss[k]);
						int itmp = Integer.parseInt(tmp.toString());
						StringBuilder stmp = new StringBuilder(s);
						stmp.deleteCharAt(k);
						stmp.deleteCharAt(j);
						stmp.deleteCharAt(i);
						max = Math.max(max, itmp + max(stmp.toString()));
					}
				}
			}
		}

		return max;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0