結果

問題 No.332 数列をプレゼントに
ユーザー asi1024asi1024
提出日時 2016-02-21 22:26:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 166,084 KB
実行使用メモリ 19,672 KB
最終ジャッジ日時 2023-10-23 18:50:25
合計ジャッジ時間 18,340 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
19,664 KB
testcase_01 AC 14 ms
19,664 KB
testcase_02 AC 9 ms
19,664 KB
testcase_03 AC 9 ms
19,664 KB
testcase_04 AC 6 ms
19,668 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
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 RE -
testcase_24 AC 240 ms
19,668 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 241 ms
19,668 KB
testcase_36 AC 7 ms
19,664 KB
testcase_37 WA -
testcase_38 AC 238 ms
19,668 KB
testcase_39 WA -
testcase_40 AC 263 ms
19,668 KB
testcase_41 AC 262 ms
19,668 KB
testcase_42 AC 262 ms
19,668 KB
testcase_43 AC 261 ms
19,668 KB
testcase_44 WA -
testcase_45 AC 257 ms
19,668 KB
testcase_46 AC 119 ms
19,664 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]] = 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