結果

問題 No.332 数列をプレゼントに
ユーザー mkawa2mkawa2
提出日時 2023-04-25 23:05:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,959 bytes
コンパイル時間 1,003 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 166,496 KB
最終ジャッジ日時 2024-04-27 07:21:30
合計ジャッジ時間 13,804 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,740 KB
testcase_01 AC 38 ms
52,560 KB
testcase_02 AC 38 ms
52,980 KB
testcase_03 AC 39 ms
53,932 KB
testcase_04 AC 40 ms
53,400 KB
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 44 ms
61,420 KB
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
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 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 37 ms
52,820 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 AC 144 ms
148,552 KB
testcase_42 AC 148 ms
148,364 KB
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
権限があれば一括ダウンロードができます

ソースコード

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 a>x: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