結果
問題 |
No.332 数列をプレゼントに
|
ユーザー |
![]() |
提出日時 | 2015-12-25 23:46:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,828 bytes |
コンパイル時間 | 3,570 ms |
コンパイル使用メモリ | 110,336 KB |
実行使用メモリ | 184,060 KB |
最終ジャッジ日時 | 2024-09-19 00:06:28 |
合計ジャッジ時間 | 7,878 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 2 TLE * 1 -- * 39 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));} }