結果

問題 No.437 cwwゲーム
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-18 02:38:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 4,049 ms
コンパイル使用メモリ 78,572 KB
実行使用メモリ 46,828 KB
最終ジャッジ日時 2024-04-20 13:21:12
合計ジャッジ時間 11,595 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,204 KB
testcase_01 AC 133 ms
41,116 KB
testcase_02 AC 147 ms
41,320 KB
testcase_03 AC 135 ms
41,212 KB
testcase_04 AC 138 ms
41,416 KB
testcase_05 AC 135 ms
41,252 KB
testcase_06 AC 142 ms
41,196 KB
testcase_07 AC 177 ms
46,076 KB
testcase_08 AC 163 ms
43,372 KB
testcase_09 AC 175 ms
45,704 KB
testcase_10 AC 171 ms
44,780 KB
testcase_11 AC 134 ms
41,220 KB
testcase_12 AC 139 ms
41,032 KB
testcase_13 AC 142 ms
41,160 KB
testcase_14 AC 149 ms
41,776 KB
testcase_15 AC 183 ms
46,828 KB
testcase_16 AC 135 ms
41,140 KB
testcase_17 AC 141 ms
41,336 KB
testcase_18 AC 143 ms
41,112 KB
testcase_19 AC 132 ms
41,292 KB
testcase_20 AC 135 ms
41,276 KB
testcase_21 AC 130 ms
41,064 KB
testcase_22 AC 135 ms
41,340 KB
testcase_23 AC 137 ms
41,256 KB
testcase_24 AC 131 ms
41,448 KB
testcase_25 AC 134 ms
41,060 KB
testcase_26 AC 135 ms
41,448 KB
testcase_27 AC 131 ms
41,272 KB
testcase_28 AC 132 ms
41,172 KB
testcase_29 AC 138 ms
41,080 KB
testcase_30 AC 137 ms
40,936 KB
testcase_31 AC 136 ms
41,692 KB
testcase_32 AC 134 ms
41,044 KB
testcase_33 AC 140 ms
41,504 KB
testcase_34 AC 136 ms
40,920 KB
testcase_35 AC 137 ms
41,132 KB
testcase_36 AC 133 ms
41,240 KB
testcase_37 AC 134 ms
41,360 KB
testcase_38 AC 133 ms
41,416 KB
testcase_39 AC 133 ms
41,448 KB
testcase_40 AC 132 ms
41,172 KB
testcase_41 AC 137 ms
41,300 KB
testcase_42 AC 142 ms
41,244 KB
testcase_43 AC 137 ms
41,080 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