結果

問題 No.332 数列をプレゼントに
ユーザー asi1024asi1024
提出日時 2016-02-21 22:34:48
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 920 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 166,144 KB
実行使用メモリ 19,696 KB
最終ジャッジ日時 2023-10-23 18:53:40
合計ジャッジ時間 12,547 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
19,644 KB
testcase_01 AC 12 ms
19,644 KB
testcase_02 AC 9 ms
19,644 KB
testcase_03 AC 8 ms
19,644 KB
testcase_04 AC 6 ms
19,648 KB
testcase_05 AC 98 ms
19,648 KB
testcase_06 AC 115 ms
19,648 KB
testcase_07 RE -
testcase_08 AC 124 ms
19,648 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 89 ms
19,648 KB
testcase_12 AC 155 ms
19,648 KB
testcase_13 AC 121 ms
19,648 KB
testcase_14 AC 73 ms
19,648 KB
testcase_15 AC 140 ms
19,648 KB
testcase_16 AC 122 ms
19,648 KB
testcase_17 WA -
testcase_18 AC 147 ms
19,648 KB
testcase_19 WA -
testcase_20 AC 140 ms
19,648 KB
testcase_21 AC 153 ms
19,648 KB
testcase_22 AC 133 ms
19,648 KB
testcase_23 RE -
testcase_24 AC 158 ms
19,648 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 150 ms
19,648 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 152 ms
19,648 KB
testcase_36 AC 6 ms
19,644 KB
testcase_37 AC 149 ms
19,648 KB
testcase_38 AC 149 ms
19,648 KB
testcase_39 AC 148 ms
19,648 KB
testcase_40 AC 164 ms
19,648 KB
testcase_41 AC 165 ms
19,648 KB
testcase_42 AC 165 ms
19,648 KB
testcase_43 AC 168 ms
19,648 KB
testcase_44 AC 166 ms
19,648 KB
testcase_45 AC 164 ms
19,648 KB
testcase_46 AC 75 ms
19,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef long long ll;

int dp[4096000];

string solve() {
  int N; ll X;
  cin >> N >> X;
  memset(dp, -1, sizeof(dp));
  dp[0] = 0;
  vector<int> A(N);
  vector<pair<int,ll>> B;
  REP(i,N) {
    cin >> A[i];
    if (A[i] < 100000) {
      for (int j = 2010000; j >= 0; --j)
        if (dp[j] >= 0 && dp[j+A[i]] == -1) dp[j+A[i]] = i;
    }
    else B.emplace_back(i, A[i]);
  }
  int M = B.size();
  REP(bit,1<<M) {
    ll sum = 0;
    REP(i,M) if ((bit >> i) & 1) sum += B[i].second;
    if (X - sum < 4096000 && dp[X-sum] >= 0) {
      string res(N, 'x');
      REP(i,M) if ((bit >> i) & 1) res[B[i].first] = 'o';
      for (int val = X - sum; val > 0; val -= A[dp[val]])
        res[dp[val]] = 'o';
      return res;
    }
  }
  return "No";
}

int main() { cout << solve() << endl; }
0