結果

問題 No.437 cwwゲーム
ユーザー uafr_csuafr_cs
提出日時 2016-10-28 22:33:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 1,224 bytes
コンパイル時間 2,681 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 41,360 KB
最終ジャッジ日時 2024-04-20 12:58:00
合計ジャッジ時間 8,099 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
40,472 KB
testcase_01 AC 108 ms
41,228 KB
testcase_02 AC 119 ms
41,248 KB
testcase_03 AC 110 ms
41,044 KB
testcase_04 AC 98 ms
40,124 KB
testcase_05 AC 110 ms
40,300 KB
testcase_06 AC 111 ms
40,764 KB
testcase_07 AC 132 ms
41,000 KB
testcase_08 AC 131 ms
41,184 KB
testcase_09 AC 134 ms
41,256 KB
testcase_10 AC 135 ms
41,036 KB
testcase_11 AC 117 ms
40,940 KB
testcase_12 AC 123 ms
41,160 KB
testcase_13 AC 123 ms
41,280 KB
testcase_14 AC 109 ms
41,260 KB
testcase_15 AC 116 ms
40,876 KB
testcase_16 AC 135 ms
41,208 KB
testcase_17 AC 111 ms
41,080 KB
testcase_18 AC 104 ms
39,916 KB
testcase_19 AC 111 ms
41,360 KB
testcase_20 AC 108 ms
41,020 KB
testcase_21 AC 99 ms
40,008 KB
testcase_22 AC 115 ms
40,988 KB
testcase_23 AC 121 ms
41,004 KB
testcase_24 AC 95 ms
39,652 KB
testcase_25 AC 123 ms
40,624 KB
testcase_26 AC 117 ms
40,904 KB
testcase_27 AC 106 ms
40,876 KB
testcase_28 AC 108 ms
40,856 KB
testcase_29 AC 101 ms
40,736 KB
testcase_30 AC 105 ms
41,052 KB
testcase_31 AC 109 ms
41,004 KB
testcase_32 AC 112 ms
41,308 KB
testcase_33 AC 114 ms
41,068 KB
testcase_34 AC 112 ms
40,988 KB
testcase_35 AC 106 ms
40,296 KB
testcase_36 AC 110 ms
41,040 KB
testcase_37 AC 122 ms
41,144 KB
testcase_38 AC 103 ms
40,028 KB
testcase_39 AC 112 ms
40,776 KB
testcase_40 AC 109 ms
41,084 KB
testcase_41 AC 103 ms
40,068 KB
testcase_42 AC 115 ms
41,112 KB
testcase_43 AC 114 ms
41,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final char[] chs = sc.next().toCharArray();
		final int len = chs.length;
		final int size = 1 << len;
		
		int[] cost = new int[size];
		
		for(int bit = 0; bit < size; bit++){
			for(int i = 0; i < len; i++){
				if((bit & (1 << i)) != 0){ continue; }
				if(chs[i] == '0'){ continue; }
				
				for(int j = i + 1; j < len; j++){
					if((bit & (1 << j)) != 0){ continue; }
					if(chs[j] == chs[i]){ continue; }
					
					for(int k = j + 1; k < len; k++){
						if((bit & (1 << k)) != 0){ continue;}
						if(chs[k] != chs[j]){ continue; }
						
						final int next_bit = bit | (1 << i) | (1 << j) | (1 << k);
						final int next_cost = (chs[i] - '0') * 100 + (chs[j] - '0') * 10 + (chs[k] - '0');
						
						cost[next_bit] = Math.max(cost[next_bit], cost[bit] + next_cost);
					}
				}
			}
		}
		
		System.out.println(Arrays.stream(cost).max().getAsInt());
	}

}
0