結果

問題 No.332 数列をプレゼントに
ユーザー koprickykopricky
提出日時 2017-07-26 07:23:47
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,515 bytes
コンパイル時間 1,712 ms
コンパイル使用メモリ 176,616 KB
実行使用メモリ 68,828 KB
最終ジャッジ日時 2024-04-17 23:46:37
合計ジャッジ時間 11,645 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,248 KB
testcase_01 AC 8 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 103 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 40 ms
7,900 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 90 ms
5,376 KB
testcase_17 AC 103 ms
5,376 KB
testcase_18 AC 1,608 ms
68,828 KB
testcase_19 AC 128 ms
5,468 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 106 ms
5,376 KB
testcase_25 AC 108 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 106 ms
5,376 KB
testcase_29 AC 107 ms
5,376 KB
testcase_30 WA -
testcase_31 AC 108 ms
5,376 KB
testcase_32 AC 109 ms
5,376 KB
testcase_33 AC 111 ms
5,376 KB
testcase_34 AC 142 ms
5,468 KB
testcase_35 AC 282 ms
11,488 KB
testcase_36 AC 5 ms
5,376 KB
testcase_37 WA -
testcase_38 AC 108 ms
5,376 KB
testcase_39 WA -
testcase_40 AC 119 ms
5,376 KB
testcase_41 AC 119 ms
5,376 KB
testcase_42 AC 119 ms
5,376 KB
testcase_43 AC 119 ms
5,376 KB
testcase_44 WA -
testcase_45 AC 116 ms
5,376 KB
testcase_46 AC 53 ms
5,376 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()){
        for(int j=1000001;j>=0;j--){
            if(j+u[i] <= 1000000 && dp[j] >= 1){
                dp[j+u[i]]++;
                last[j+u[i]] = i;
            }
        }
    }
    vector<int> 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,vec.size()){
        int cnt = upper_bound(all(vec2),x-vec[i])-lower_bound(all(vec2),x-vec[i]);
        if(cnt >= 1){
            int bf = vec[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[x-vec[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