結果

問題 No.437 cwwゲーム
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-18 02:38:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 4,494 ms
コンパイル使用メモリ 81,312 KB
実行使用メモリ 60,760 KB
最終ジャッジ日時 2023-08-02 13:14:25
合計ジャッジ時間 10,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,380 KB
testcase_01 AC 121 ms
55,516 KB
testcase_02 AC 131 ms
55,576 KB
testcase_03 AC 124 ms
55,708 KB
testcase_04 AC 120 ms
56,156 KB
testcase_05 AC 119 ms
55,872 KB
testcase_06 AC 129 ms
56,396 KB
testcase_07 AC 163 ms
60,352 KB
testcase_08 AC 151 ms
57,484 KB
testcase_09 AC 171 ms
60,724 KB
testcase_10 AC 172 ms
60,760 KB
testcase_11 AC 123 ms
55,500 KB
testcase_12 AC 125 ms
55,584 KB
testcase_13 AC 134 ms
55,512 KB
testcase_14 AC 133 ms
55,712 KB
testcase_15 AC 178 ms
60,476 KB
testcase_16 AC 122 ms
55,308 KB
testcase_17 AC 127 ms
56,256 KB
testcase_18 AC 129 ms
55,376 KB
testcase_19 AC 122 ms
55,356 KB
testcase_20 AC 123 ms
55,288 KB
testcase_21 AC 121 ms
55,516 KB
testcase_22 AC 128 ms
55,708 KB
testcase_23 AC 124 ms
55,588 KB
testcase_24 AC 121 ms
55,504 KB
testcase_25 AC 128 ms
55,288 KB
testcase_26 AC 127 ms
55,832 KB
testcase_27 AC 123 ms
55,564 KB
testcase_28 AC 123 ms
55,588 KB
testcase_29 AC 124 ms
55,596 KB
testcase_30 AC 123 ms
55,504 KB
testcase_31 AC 122 ms
56,488 KB
testcase_32 AC 122 ms
55,872 KB
testcase_33 AC 125 ms
55,560 KB
testcase_34 AC 122 ms
55,576 KB
testcase_35 AC 123 ms
55,712 KB
testcase_36 AC 123 ms
55,688 KB
testcase_37 AC 123 ms
53,672 KB
testcase_38 AC 121 ms
55,612 KB
testcase_39 AC 120 ms
55,704 KB
testcase_40 AC 118 ms
55,856 KB
testcase_41 AC 124 ms
56,012 KB
testcase_42 AC 124 ms
55,876 KB
testcase_43 AC 122 ms
56,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.Arrays;

public class CWWGame{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		String s = sc.nextLine();
		int max_cww = new CWWGame().get_max_cww(s);
		System.out.println(max_cww);
	}

	int get_max_cww(String s){
		char[] ss = s.toCharArray();
		int n = s.length();
		int max_cww = 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]);
						sb.append(ss[j]);
						sb.append(ss[k]);
						int cww = Integer.parseInt(sb.toString());
						
						StringBuilder sb2 = new StringBuilder(s);
						sb2.deleteCharAt(k);
						sb2.deleteCharAt(j);
						sb2.deleteCharAt(i);

						max_cww = Math.max(max_cww, cww+get_max_cww(sb2.toString()));
					}
				}
			}
		}
		return max_cww;
	}
}
0