結果

問題 No.332 数列をプレゼントに
ユーザー sigma425sigma425
提出日時 2015-12-25 00:50:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 697 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 1,234 ms
コンパイル使用メモリ 154,688 KB
実行使用メモリ 185,884 KB
最終ジャッジ日時 2023-08-25 21:11:27
合計ジャッジ時間 5,548 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,588 KB
testcase_01 AC 3 ms
9,476 KB
testcase_02 AC 2 ms
5,412 KB
testcase_03 AC 2 ms
5,700 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 27 ms
118,080 KB
testcase_06 AC 29 ms
134,620 KB
testcase_07 AC 27 ms
120,652 KB
testcase_08 AC 28 ms
120,860 KB
testcase_09 AC 4 ms
15,632 KB
testcase_10 AC 9 ms
30,264 KB
testcase_11 AC 25 ms
112,012 KB
testcase_12 AC 28 ms
121,360 KB
testcase_13 AC 26 ms
120,484 KB
testcase_14 AC 18 ms
81,300 KB
testcase_15 AC 27 ms
121,120 KB
testcase_16 AC 30 ms
121,280 KB
testcase_17 AC 25 ms
120,500 KB
testcase_18 AC 46 ms
121,876 KB
testcase_19 AC 147 ms
136,884 KB
testcase_20 AC 27 ms
121,280 KB
testcase_21 AC 25 ms
120,716 KB
testcase_22 AC 26 ms
121,144 KB
testcase_23 AC 30 ms
121,596 KB
testcase_24 AC 29 ms
121,880 KB
testcase_25 AC 28 ms
121,292 KB
testcase_26 AC 30 ms
121,716 KB
testcase_27 AC 27 ms
121,140 KB
testcase_28 AC 29 ms
121,544 KB
testcase_29 AC 30 ms
121,904 KB
testcase_30 AC 29 ms
121,360 KB
testcase_31 AC 28 ms
121,364 KB
testcase_32 AC 30 ms
121,604 KB
testcase_33 AC 51 ms
124,564 KB
testcase_34 AC 152 ms
136,940 KB
testcase_35 AC 697 ms
185,884 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 25 ms
120,380 KB
testcase_38 AC 25 ms
120,380 KB
testcase_39 AC 25 ms
120,392 KB
testcase_40 AC 24 ms
120,400 KB
testcase_41 AC 25 ms
120,524 KB
testcase_42 AC 25 ms
120,308 KB
testcase_43 AC 25 ms
120,712 KB
testcase_44 AC 25 ms
120,612 KB
testcase_45 AC 38 ms
123,904 KB
testcase_46 AC 19 ms
91,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long ll;
int N;
ll X,a[100];
vector<int> ls,ss;		//large,small
typedef pair<ll,int> P;
set<P> st;
bool dp[101][2227601];
int main(){
	cin>>N>>X;
	rep(i,N) cin>>a[i];
	rep(i,N){
		if(a[i]>=22276) ls.pb(i);
		else ss.pb(i);
	}
	int K=ls.size();
	rep(i,1<<K){
		ll S=0;
		rep(j,K) if((i>>j)&1) S+=a[ls[j]];
		st.insert(P(S,i));
	}
	int B=ss.size();
	int S=0;
	dp[0][0]=1;
	rep(i,B){
		rep(j,S+1){
			if(dp[i][j]) dp[i+1][j+a[ss[i]]]=1,dp[i+1][j]=1;
		}
		S+=a[ss[i]];
	}
	rep(j,S+1) if(dp[B][j]){
		auto it=st.lower_bound(P(X-j,0));
		if(it==st.end()||it->fs!=X-j) continue;
		string ans(N,'x');
		int s=j;
		for(int i=B-1;i>=0;i--){
			if(!dp[i][s]) s-=a[ss[i]],ans[ss[i]]='o';
		}
		int id=it->sc;
		rep(i,K) if((id>>i)&1) ans[ls[i]]='o';
		cout<<ans<<endl;
		return 0;
	}
	puts("No");
}
0