結果
| 問題 |
No.332 数列をプレゼントに
|
| ユーザー |
🐬hec
|
| 提出日時 | 2015-12-25 01:47:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 896 bytes |
| コンパイル時間 | 1,650 ms |
| コンパイル使用メモリ | 171,108 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-18 23:39:46 |
| 合計ジャッジ時間 | 10,771 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 22 WA * 20 |
ソースコード
#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;
rep(i,n) cin >> a[i];
sort(a,a+n);
const int m=min(n,20);
const int offset=n-m;
dp[0][0]=-1;
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];
}
reverse(ans.begin(),ans.end());
cout << ans << endl;
return 0;
}
}
puts("No");
return 0;
}
🐬hec