結果

問題 No.332 数列をプレゼントに
ユーザー 🐬hec🐬hec
提出日時 2015-12-25 02:13:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 173,052 KB
実行使用メモリ 4,772 KB
最終ジャッジ日時 2023-10-19 03:28:21
合計ジャッジ時間 10,793 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 244 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 237 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 245 ms
4,348 KB
testcase_25 AC 237 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 239 ms
4,348 KB
testcase_29 AC 236 ms
4,348 KB
testcase_30 WA -
testcase_31 AC 236 ms
4,348 KB
testcase_32 AC 239 ms
4,348 KB
testcase_33 AC 238 ms
4,348 KB
testcase_34 AC 245 ms
4,348 KB
testcase_35 AC 245 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 246 ms
4,348 KB
testcase_38 AC 246 ms
4,348 KB
testcase_39 AC 245 ms
4,348 KB
testcase_40 AC 247 ms
4,348 KB
testcase_41 AC 235 ms
4,348 KB
testcase_42 AC 238 ms
4,348 KB
testcase_43 AC 256 ms
4,348 KB
testcase_44 WA -
testcase_45 AC 253 ms
4,348 KB
testcase_46 AC 255 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long ;

int n;
ll x,a[110];
map<ll,ll> dp[110];

int main(void){
	cin >> n >> x;
	const int m=min(n,20);
	const int offset=n-m;
	
	rep(i,n) cin >> a[i];
	sort(a,a+n);

	dp[0][0]=-1LL;
	rep(i,offset){
		for(auto &it:dp[i]){
			ll cur=it.first;
			dp[i+1][cur]=cur;
			dp[i+1][cur+a[i]]=cur;
		}		
	}

	rep(mask,1<<m){
		ll cur=0LL;
		string ans="";
		rep(i,m){
			if(mask&(1<<i)){
				cur+=a[i+offset];
				ans+="o";
			}else{
				ans+="x";
			}
		}

		if(x<cur) continue;
		cur=x-cur;

		if(dp[offset].find(cur)!=dp[offset].end()){
			reverse(ans.begin(),ans.end());	
			for(int i=offset;i>0;--i){
				if(cur!=dp[i][cur]){
					ans+="o";
				}else{
					ans+="x";
				}
				cur=dp[i][cur];
			}
			assert(cur==0LL);
			reverse(ans.begin(),ans.end());
			cout << ans << endl;
			return 0;
		}
	}
	puts("No");
	return 0;
}

0