結果

問題 No.437 cwwゲーム
ユーザー YamaKasaYamaKasa
提出日時 2018-09-21 22:19:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 74,124 KB
実行使用メモリ 59,636 KB
最終ジャッジ日時 2023-09-25 10:51:31
合計ジャッジ時間 8,968 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,840 KB
testcase_01 AC 115 ms
56,288 KB
testcase_02 AC 121 ms
55,316 KB
testcase_03 AC 116 ms
55,756 KB
testcase_04 AC 116 ms
55,468 KB
testcase_05 AC 123 ms
58,244 KB
testcase_06 AC 149 ms
59,120 KB
testcase_07 AC 149 ms
59,268 KB
testcase_08 AC 148 ms
57,400 KB
testcase_09 AC 151 ms
59,328 KB
testcase_10 AC 148 ms
56,812 KB
testcase_11 AC 119 ms
55,872 KB
testcase_12 AC 117 ms
55,812 KB
testcase_13 AC 121 ms
55,964 KB
testcase_14 AC 124 ms
55,656 KB
testcase_15 AC 153 ms
59,636 KB
testcase_16 AC 117 ms
55,864 KB
testcase_17 AC 120 ms
55,856 KB
testcase_18 AC 120 ms
55,952 KB
testcase_19 WA -
testcase_20 AC 115 ms
55,720 KB
testcase_21 AC 116 ms
56,076 KB
testcase_22 AC 116 ms
55,856 KB
testcase_23 AC 117 ms
55,940 KB
testcase_24 AC 118 ms
55,688 KB
testcase_25 AC 117 ms
55,524 KB
testcase_26 AC 120 ms
56,092 KB
testcase_27 AC 116 ms
56,036 KB
testcase_28 AC 115 ms
56,076 KB
testcase_29 AC 116 ms
55,856 KB
testcase_30 AC 115 ms
55,820 KB
testcase_31 AC 117 ms
55,624 KB
testcase_32 AC 117 ms
55,656 KB
testcase_33 AC 120 ms
55,676 KB
testcase_34 AC 114 ms
55,712 KB
testcase_35 AC 113 ms
55,688 KB
testcase_36 AC 114 ms
55,888 KB
testcase_37 AC 115 ms
55,504 KB
testcase_38 AC 119 ms
55,820 KB
testcase_39 AC 123 ms
55,332 KB
testcase_40 AC 120 ms
56,084 KB
testcase_41 AC 120 ms
55,640 KB
testcase_42 AC 118 ms
55,324 KB
testcase_43 AC 118 ms
55,928 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