結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー vwxyzvwxyz
提出日時 2024-04-15 11:45:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 619 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 79,120 KB
最終ジャッジ日時 2024-04-15 11:45:35
合計ジャッジ時間 7,581 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
73,100 KB
testcase_01 AC 185 ms
69,960 KB
testcase_02 AC 587 ms
78,624 KB
testcase_03 AC 516 ms
78,492 KB
testcase_04 AC 53 ms
55,948 KB
testcase_05 AC 44 ms
55,340 KB
testcase_06 AC 44 ms
54,848 KB
testcase_07 AC 45 ms
54,836 KB
testcase_08 AC 161 ms
69,412 KB
testcase_09 AC 44 ms
54,908 KB
testcase_10 AC 44 ms
54,508 KB
testcase_11 AC 44 ms
54,672 KB
testcase_12 AC 81 ms
65,492 KB
testcase_13 AC 45 ms
54,360 KB
testcase_14 AC 44 ms
55,316 KB
testcase_15 AC 44 ms
54,924 KB
testcase_16 AC 43 ms
55,112 KB
testcase_17 AC 45 ms
54,976 KB
testcase_18 AC 44 ms
54,332 KB
testcase_19 AC 44 ms
55,312 KB
testcase_20 AC 44 ms
54,924 KB
testcase_21 AC 43 ms
55,464 KB
testcase_22 AC 45 ms
54,812 KB
testcase_23 AC 43 ms
55,364 KB
testcase_24 AC 44 ms
54,052 KB
testcase_25 AC 55 ms
54,692 KB
testcase_26 AC 44 ms
56,232 KB
testcase_27 AC 44 ms
54,992 KB
testcase_28 AC 44 ms
54,468 KB
testcase_29 AC 44 ms
55,304 KB
testcase_30 AC 44 ms
54,308 KB
testcase_31 AC 43 ms
54,228 KB
testcase_32 AC 67 ms
65,088 KB
testcase_33 AC 54 ms
65,012 KB
testcase_34 AC 118 ms
67,820 KB
testcase_35 AC 612 ms
78,708 KB
testcase_36 AC 329 ms
75,196 KB
testcase_37 AC 619 ms
79,120 KB
testcase_38 AC 611 ms
78,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N=int(input())
inf=1<<30
dp=[inf]*(N+1)
dp[0]=0
for i in range(1,N+1):
    for j in range(1,int(i**.5)+1):
        dp[i]=min(dp[i],dp[i-j*j]+j)
lst=[[],[]]
i=N
while i:
    for j in range(1,int(i**.5)+1,2):
        if dp[i]==dp[i-j*j]+j:
            i-=j*j
            lst[j%2].append(j)
            break
    else:
        for j in range(2,int(i**.5)+1,2):
            if dp[i]==dp[i-j*j]+j:
                i-=j*j
                lst[j%2].append(j)
                break
ans_lst=[]
lst[0].sort()
lst[1].sort()
for x in lst[1]:
    for i in range(x):
        ans_lst.append(i%2)
p=0
queue=deque(lst[0])
while queue:
    if p:
        x=queue.popleft()
    else:
        x=queue.pop()
    for i in range(x):
        ans_lst.append((i+p)%2)
    p^=1
print(*ans_lst,sep="")
0