結果

問題 No.332 数列をプレゼントに
ユーザー mkawa2mkawa2
提出日時 2023-04-25 23:15:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,969 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 149,460 KB
最終ジャッジ日時 2024-04-27 07:28:04
合計ジャッジ時間 9,149 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,740 KB
testcase_01 AC 36 ms
52,332 KB
testcase_02 AC 36 ms
53,148 KB
testcase_03 AC 35 ms
52,820 KB
testcase_04 AC 36 ms
53,352 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 135 ms
148,544 KB
testcase_08 WA -
testcase_09 AC 39 ms
60,744 KB
testcase_10 AC 128 ms
148,528 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 123 ms
148,212 KB
testcase_17 AC 129 ms
148,824 KB
testcase_18 WA -
testcase_19 AC 130 ms
148,612 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 133 ms
148,588 KB
testcase_25 AC 133 ms
149,112 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 135 ms
148,528 KB
testcase_29 AC 133 ms
148,524 KB
testcase_30 WA -
testcase_31 AC 131 ms
148,772 KB
testcase_32 AC 138 ms
148,620 KB
testcase_33 AC 135 ms
148,732 KB
testcase_34 AC 131 ms
148,852 KB
testcase_35 AC 133 ms
148,588 KB
testcase_36 AC 36 ms
54,464 KB
testcase_37 WA -
testcase_38 AC 134 ms
148,536 KB
testcase_39 WA -
testcase_40 AC 130 ms
148,292 KB
testcase_41 AC 135 ms
148,368 KB
testcase_42 AC 133 ms
148,556 KB
testcase_43 AC 136 ms
148,472 KB
testcase_44 WA -
testcase_45 AC 142 ms
148,656 KB
testcase_46 AC 135 ms
148,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# md = 10**9+7
md = 998244353

n, x = LI()
aa = LI()

if n <= 20:
    sa = [(0, 0)]
    for i, a in enumerate(aa):
        s = 1 << i
        nsa = []
        for t, b in sa:
            nsa.append((s | t, a+b))
        sa += nsa

    for s,a in sa:
        if a==x:
            ans=""
            for i in range(n):
                if s>>i&1:
                    ans+="o"
                else:
                    ans+="x"
            print(ans)
            exit()

else:
    ia = sorted(enumerate(aa), key=lambda x: -x[1])
    sa = [(0, 0)]
    for i in range(20):
        s = 1 << i
        a=ia[i][1]
        nsa = []
        for t, b in sa:
            nsa.append((s | t, a+b))
        sa += nsa

    t=sum(a for _,a in  ia[20:])
    dp=[-1]*(t+1)
    dp[0]=0
    for i,a in ia[20:]:
        for j in range(t-a,-1,-1):
            if dp[j]==-1:continue
            dp[j+a]=i

    ans=[0]*n
    for s,a in sa:
        if not 0<=x-a<=t:continue
        if dp[x-a]==-1:continue
        for j in range(n):
            if s>>j&1:
                i=ia[j][0]
                ans[i]=1
        x-=a
        while x:
            i=dp[x]
            ans[i]=1
            x-=aa[i]

        print("".join("o" if a else "x" for a in ans))
        exit()

print("No")
0