結果

問題 No.625 ソンタクロース
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-03 13:46:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 204 ms / 4,000 ms
コード長 1,139 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 10,364 KB
最終ジャッジ日時 2023-10-19 21:18:09
合計ジャッジ時間 3,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,228 KB
testcase_01 AC 31 ms
10,228 KB
testcase_02 AC 31 ms
10,228 KB
testcase_03 AC 31 ms
10,228 KB
testcase_04 AC 31 ms
10,228 KB
testcase_05 AC 30 ms
10,228 KB
testcase_06 AC 31 ms
10,228 KB
testcase_07 AC 29 ms
10,228 KB
testcase_08 AC 29 ms
10,228 KB
testcase_09 AC 30 ms
10,228 KB
testcase_10 AC 30 ms
10,228 KB
testcase_11 AC 30 ms
10,228 KB
testcase_12 AC 31 ms
10,228 KB
testcase_13 AC 30 ms
10,228 KB
testcase_14 AC 30 ms
10,228 KB
testcase_15 AC 46 ms
10,272 KB
testcase_16 AC 38 ms
10,256 KB
testcase_17 AC 103 ms
10,320 KB
testcase_18 AC 204 ms
10,364 KB
testcase_19 AC 57 ms
10,284 KB
testcase_20 AC 58 ms
10,284 KB
testcase_21 AC 45 ms
10,272 KB
testcase_22 AC 169 ms
10,356 KB
testcase_23 AC 42 ms
10,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
lst = [m]
tmp = []

def opposite():
    lst.insert(0,-1)

for i in range(2,n+1):
    p = (i+2)//2
    get_p = 1
    use_m = 0
    tmp = []
    over0 = []
    for j in range(i-1):
        apd = 0
        if lst[j]==0:
            get_p+=1
            use_m+=1
            apd = 1
        elif lst[j]==-1:
            get_p+=1
        else:
            over0.append(lst[j])
        tmp.append(apd)
    if get_p>p:
        get_p -= p
        p = get_p
        use_m -= p
        for j in range(p):
            for k in range(i-1):
                if tmp[k]==1:
                    tmp[k]=0
                    break
    if get_p==p:
        if use_m<=m:
            lst = [m-use_m]+tmp[:]
        else:
            opposite()
        continue
    
    p -= get_p
    over0.sort()
    if m < use_m+sum(over0[:p])+p:
        opposite()
    else:
        for j in range(p):
            for l in range(i-2,-1,-1):
                if lst[l]==1:
                    lst[l] = 2
                    tmp[l] = lst[l]
                    use_m += lst[l]
                    break
        lst = [m-use_m]+tmp[:]
print(*lst)
0