結果

問題 No.437 cwwゲーム
ユーザー kuuso1
提出日時 2016-10-29 20:19:17
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,391 bytes
コンパイル時間 1,640 ms
コンパイル使用メモリ 116,108 KB
実行使用メモリ 26,972 KB
最終ジャッジ日時 2024-10-12 08:32:59
合計ジャッジ時間 4,195 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		int[] dp = new int[1<<N];
		for(int t=0;t<(1<<N);t++){
			for(int i=0;i<N;i++){
				for(int j=i+1;j<N;j++){
					for(int k=j+1;k<N;k++){
						if( ((t>>i)&1) == 0 && ((t>>j)&1) == 0 && ((t>>k)&1) == 0 && S[i] != S[j] && S[j] == S[k] && S[i] != 0){
							dp[ t | (1<<i) | (1<<j) | (1<<k) ] = Math.Max(dp[ t | (1<<i) | (1<<j) | (1<<k) ],dp[t]+100*S[i]+10*S[j]+S[k]);
						}
					}
				}
			}
		}
		Console.WriteLine(dp.Max());
		
		
		
	}
	int[] S;
	public Sol(){
		S = rs().Select(c => (int) c - '0').ToArray();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0