結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,736 KB
testcase_01 AC 119 ms
55,440 KB
testcase_02 AC 127 ms
53,704 KB
testcase_03 AC 117 ms
55,400 KB
testcase_04 AC 117 ms
55,728 KB
testcase_05 AC 125 ms
55,840 KB
testcase_06 AC 150 ms
56,768 KB
testcase_07 WA -
testcase_08 AC 160 ms
59,368 KB
testcase_09 WA -
testcase_10 AC 166 ms
59,916 KB
testcase_11 AC 119 ms
57,888 KB
testcase_12 AC 119 ms
55,744 KB
testcase_13 AC 125 ms
55,648 KB
testcase_14 AC 129 ms
55,564 KB
testcase_15 AC 164 ms
59,960 KB
testcase_16 AC 118 ms
55,496 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 116 ms
55,816 KB
testcase_21 AC 114 ms
55,176 KB
testcase_22 AC 115 ms
55,424 KB
testcase_23 AC 116 ms
55,432 KB
testcase_24 AC 117 ms
55,800 KB
testcase_25 AC 119 ms
55,508 KB
testcase_26 AC 118 ms
55,808 KB
testcase_27 AC 115 ms
55,720 KB
testcase_28 AC 115 ms
55,196 KB
testcase_29 AC 115 ms
53,360 KB
testcase_30 AC 114 ms
55,800 KB
testcase_31 AC 118 ms
55,496 KB
testcase_32 AC 114 ms
55,604 KB
testcase_33 AC 120 ms
55,604 KB
testcase_34 AC 115 ms
55,452 KB
testcase_35 AC 114 ms
55,732 KB
testcase_36 AC 114 ms
55,832 KB
testcase_37 AC 115 ms
55,780 KB
testcase_38 AC 116 ms
55,904 KB
testcase_39 AC 118 ms
55,732 KB
testcase_40 AC 114 ms
55,764 KB
testcase_41 AC 118 ms
55,728 KB
testcase_42 AC 117 ms
55,416 KB
testcase_43 AC 118 ms
55,476 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;
		String s1 = "";
		String s2 = "";
		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);
					int p = 0;
					if(c2 == c3) {
						p += 100 * Character.getNumericValue(c1);
						p += 10 * Character.getNumericValue(c2);
						p += Character.getNumericValue(c3);
						s1 = String.valueOf(c1);
						s2 = String.valueOf(c2);
						StringBuilder sb = new StringBuilder(s);
						sb.deleteCharAt(sb.indexOf(s1));
						sb.deleteCharAt(sb.indexOf(s2));
						sb.deleteCharAt(sb.indexOf(s2));
						max = Math.max(max, p + cww(sb.toString()));
					}
				}
			}
		}
		return max;
	}
}
0