結果

問題 No.437 cwwゲーム
ユーザー YamaKasaYamaKasa
提出日時 2018-09-21 22:23:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 77,552 KB
実行使用メモリ 43,972 KB
最終ジャッジ日時 2024-04-20 13:21:57
合計ジャッジ時間 7,977 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
41,064 KB
testcase_01 AC 108 ms
40,028 KB
testcase_02 AC 114 ms
41,168 KB
testcase_03 AC 97 ms
39,900 KB
testcase_04 AC 96 ms
39,984 KB
testcase_05 AC 110 ms
41,196 KB
testcase_06 AC 115 ms
41,000 KB
testcase_07 AC 142 ms
43,056 KB
testcase_08 AC 118 ms
41,308 KB
testcase_09 AC 146 ms
42,684 KB
testcase_10 AC 135 ms
42,108 KB
testcase_11 AC 97 ms
40,008 KB
testcase_12 AC 106 ms
40,668 KB
testcase_13 AC 117 ms
41,108 KB
testcase_14 AC 119 ms
40,912 KB
testcase_15 AC 146 ms
43,972 KB
testcase_16 AC 107 ms
41,164 KB
testcase_17 AC 109 ms
41,240 KB
testcase_18 AC 104 ms
39,856 KB
testcase_19 AC 98 ms
40,140 KB
testcase_20 AC 110 ms
40,916 KB
testcase_21 AC 112 ms
41,088 KB
testcase_22 AC 105 ms
40,796 KB
testcase_23 AC 108 ms
41,228 KB
testcase_24 AC 104 ms
40,860 KB
testcase_25 AC 98 ms
39,832 KB
testcase_26 AC 113 ms
41,044 KB
testcase_27 AC 101 ms
40,124 KB
testcase_28 AC 105 ms
41,136 KB
testcase_29 AC 98 ms
39,916 KB
testcase_30 AC 102 ms
40,156 KB
testcase_31 AC 96 ms
40,136 KB
testcase_32 AC 113 ms
41,464 KB
testcase_33 AC 112 ms
41,036 KB
testcase_34 AC 99 ms
39,656 KB
testcase_35 AC 107 ms
40,924 KB
testcase_36 AC 110 ms
41,028 KB
testcase_37 AC 102 ms
40,028 KB
testcase_38 AC 108 ms
41,036 KB
testcase_39 AC 113 ms
40,752 KB
testcase_40 AC 97 ms
39,772 KB
testcase_41 AC 109 ms
40,912 KB
testcase_42 AC 109 ms
41,152 KB
testcase_43 AC 109 ms
40,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		if(s.length() < 3) {
			System.out.println(0);
			System.exit(0);
		}
		System.out.println(cww(s));
	}
	static int cww(String s) {
		int l = s.length();
		if(l < 3) {
			return 0;
		}

		int max = 0;

		for(int i = 0; i < l - 2; i++) {
			char c1 = s.charAt(i);
			if(c1 == '0') {
				continue;
			}
			for(int j = i + 1; j < l - 1; j++) {
				char c2 = s.charAt(j);
				if(c2 == c1) {
					continue;
				}
				for(int k = j + 1; k < l; k++) {
					char c3 = s.charAt(k);
					if(c2 == c3) {
						int p = 0;
						p += 100 * Character.getNumericValue(c1);
						p += 10 * Character.getNumericValue(c2);
						p += Character.getNumericValue(c3);
						StringBuilder sb = new StringBuilder(s);
						sb.deleteCharAt(k);
						sb.deleteCharAt(j);
						sb.deleteCharAt(i);
						max = Math.max(max, p + cww(sb.toString()));
					}
				}
			}
		}
		return max;
	}
}
0