結果

問題 No.332 数列をプレゼントに
ユーザー snukesnuke
提出日時 2015-12-25 00:41:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 2,028 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 84,232 KB
実行使用メモリ 83,744 KB
最終ジャッジ日時 2023-08-25 21:11:21
合計ジャッジ時間 6,982 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 33 ms
45,564 KB
testcase_06 AC 45 ms
57,728 KB
testcase_07 AC 150 ms
80,260 KB
testcase_08 AC 44 ms
59,804 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 90 ms
10,620 KB
testcase_11 AC 32 ms
43,468 KB
testcase_12 AC 64 ms
82,372 KB
testcase_13 AC 48 ms
61,872 KB
testcase_14 AC 21 ms
28,976 KB
testcase_15 AC 53 ms
67,908 KB
testcase_16 AC 55 ms
72,052 KB
testcase_17 AC 63 ms
82,252 KB
testcase_18 AC 55 ms
72,056 KB
testcase_19 AC 57 ms
74,188 KB
testcase_20 AC 52 ms
68,032 KB
testcase_21 AC 57 ms
74,056 KB
testcase_22 AC 50 ms
65,860 KB
testcase_23 AC 88 ms
83,520 KB
testcase_24 AC 149 ms
83,668 KB
testcase_25 AC 150 ms
83,744 KB
testcase_26 AC 106 ms
83,536 KB
testcase_27 AC 65 ms
83,528 KB
testcase_28 AC 150 ms
83,600 KB
testcase_29 AC 149 ms
83,656 KB
testcase_30 AC 71 ms
83,596 KB
testcase_31 AC 148 ms
83,588 KB
testcase_32 AC 148 ms
83,508 KB
testcase_33 AC 148 ms
83,648 KB
testcase_34 AC 150 ms
83,524 KB
testcase_35 AC 149 ms
83,580 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 149 ms
83,540 KB
testcase_38 AC 150 ms
83,744 KB
testcase_39 AC 107 ms
83,588 KB
testcase_40 AC 153 ms
83,476 KB
testcase_41 AC 148 ms
83,652 KB
testcase_42 AC 151 ms
83,520 KB
testcase_43 AC 152 ms
83,576 KB
testcase_44 AC 67 ms
83,600 KB
testcase_45 AC 151 ms
83,588 KB
testcase_46 AC 108 ms
31,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 105, MY = 8000005, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;

int n;
ll x;
int a[MX], id[MX];
bitset<MY> dp[81];
map<int,int> mp;

int main() {
  scanf("%d%lld",&n,&x);
  rep(i,n) scanf("%d",&a[i]), id[i] = i;
  sort(id,id+n,[&](int x, int y){return a[x]<a[y];});
  int m = min(20,n);
  vi s;
  rep(i,m) s.pb(id[n-i-1]);
  n -= m;
  dp[0][0] = true;
  rep(i,n) dp[i+1] = dp[i]<<a[id[i]]|dp[i];
  rep(i,1<<m) {
    ll sum = 0;
    rep(j,m) if (i>>j&1) sum += a[s[j]];
    ll r = x-sum;
    if (0 <= r && r <= MY && dp[n][r]) {
      string ans = string(n+m,'x');
      rep(j,m) if (i>>j&1) ans[s[j]] = 'o';
      drep(j,n) {
        int na = a[id[j]];
        if (na <= r && dp[j][r-na]) ans[id[j]] = 'o', r -= na;
      }
      cout<<ans<<endl;
      return 0;
    }
  }
  puts("No");
  return 0;
}




0