結果
問題 |
No.332 数列をプレゼントに
|
ユーザー |
![]() |
提出日時 | 2015-12-25 00:34:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,136 bytes |
コンパイル時間 | 1,503 ms |
コンパイル使用メモリ | 168,416 KB |
実行使用メモリ | 345,344 KB |
最終ジャッジ日時 | 2024-09-18 23:12:14 |
合計ジャッジ時間 | 5,500 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 MLE * 1 |
other | AC * 13 MLE * 1 -- * 28 |
ソースコード
#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][1000001]; int main(){ cin>>N>>X; rep(i,N) cin>>a[i]; rep(i,N){ if(a[i]>=10000) 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"); }