結果

問題 No.332 数列をプレゼントに
ユーザー kuuso1kuuso1
提出日時 2015-12-25 23:46:10
言語 C#(csc)
(csc 3.9.0)
結果
MLE  
実行時間 -
コード長 1,828 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 112,304 KB
実行使用メモリ 331,064 KB
最終ジャッジ日時 2023-10-19 03:52:55
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
24,660 KB
testcase_01 AC 34 ms
24,628 KB
testcase_02 AC 34 ms
24,632 KB
testcase_03 AC 33 ms
24,624 KB
testcase_04 AC 34 ms
24,632 KB
testcase_05 AC 35 ms
24,620 KB
testcase_06 AC 169 ms
48,028 KB
testcase_07 MLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Numerics;
using BI=System.Numerics.BigInteger;

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

class Sol{
	public void Solve(){
		
		Pair[] AA=new Pair[N];
		for(int i=0;i<N;i++){
			AA[i]=new Pair(A[i],i);
		}
		Array.Sort(AA,(x,y)=>x.V.CompareTo(y.V));
		
		Dictionary<long,BI> dp=new Dictionary<long,BI>();
		dp.Add(0,0);
		for(int i=0;i<N;i++){
			Dictionary<long,BI> nxt=new Dictionary<long,BI>();
			foreach(var k in dp.Keys){
				if(k>X)continue;
				if(!nxt.ContainsKey(k))nxt.Add(k,dp[k]);
				if(k+AA[i].V>X)continue;
				if(!nxt.ContainsKey(k+AA[i].V)){
					nxt.Add(k+AA[i].V,dp[k]|(((BI)1)<<i));
				}
			}
			if(nxt.ContainsKey(X)){
				char[] Ans =new char[N];
				for(int ii=0;ii<N;ii++){
					Ans[AA[ii].Idx]='x';
					if(((nxt[X]>>ii)&1)==1)Ans[AA[ii].Idx]='o';
				}
				Console.WriteLine(new String(Ans));
				return;
			}
			dp=nxt;
		}
		
		Console.WriteLine("No");
		
	}
	class Pair{
		public long V;
		public int Idx;
		public Pair(long v,int i){
			V=v;Idx=i;
		}
	}
	
	long[] A;
	int N;
	long X;
	public Sol(){
		var d=rla();
		N=(int)d[0];
		X=d[1];
		A=rla();
	}




	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(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0