結果

問題 No.332 数列をプレゼントに
ユーザー koprickykopricky
提出日時 2017-07-26 07:06:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,493 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 175,428 KB
実行使用メモリ 87,772 KB
最終ジャッジ日時 2024-04-17 23:45:14
合計ジャッジ時間 11,917 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
20,020 KB
testcase_01 AC 15 ms
19,988 KB
testcase_02 AC 14 ms
19,632 KB
testcase_03 WA -
testcase_04 AC 3 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 102 ms
20,104 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
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 115 ms
20,840 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 108 ms
20,976 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 3 ms
6,940 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 80 ms
12,244 KB
testcase_41 AC 75 ms
12,240 KB
testcase_42 AC 97 ms
15,448 KB
testcase_43 AC 98 ms
15,836 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 56 ms
19,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int dp[1000001];
int last[1000001];
map<ll,int> mp;
bool flag[101];

int main()
{
    int n;
    ll x;
    cin >> n >> x;
    vector<int> u;
    vector<int> v;
    vector<int> id1,id2;
    rep(i,n){
        int a;
        cin >> a;
        if(a > 10001){
            v.pb(a);
            id1.pb(i);
        }else{
            u.pb(a);
            id2.pb(i);
        }
    }
    dp[0] = 1;
    rep(i,u.size()){
        rep(j,1000001){
            if(j-u[i] >= 0 && dp[j-u[i]] >= 1){
                dp[j]++;
                last[j] = i;
            }
        }
    }
    vector<ll> vec;
    rep(i,1000001){
        if(dp[i] > 0){
            vec.pb(i);
        }
    }
    vector<ll> vec2;
    rep(i,(1 << (int)(v.size()))){
        ll sm = 0;
        rep(j,v.size()){
            if(i & (1 << j)){
                sm += v[j];
            }
        }
        vec2.pb(sm);
        mp[sm] = i;
    }
    sort(all(vec2));
    vec2.erase(unique(all(vec2)),vec2.end());
    rep(i,vec2.size()){
        int cnt = upper_bound(all(vec),x-vec2[i])-lower_bound(all(vec),x-vec2[i]);
        if(cnt >= 1){
            int bf = x-vec2[i];
            vector<int> use;
            while(bf){
                use.pb(last[bf]);
                bf -= u[last[bf]];
            }
            rep(j,use.size()){
                flag[id2[use[j]]] = true;
            }
            use.clear();
            bf = mp[vec2[i]];
            rep(j,25){
                if(bf & (1 << j)){
                    use.pb(j);
                }
            }
            rep(j,use.size()){
                flag[id1[use[j]]] = true;
            }
            rep(j,n){
                if(flag[j]){
                    cout << 'o';
                }else{
                    cout << 'x';
                }
            }
            cout << endl;
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}
0