結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,208 KB
testcase_01 AC 31 ms
10,208 KB
testcase_02 AC 30 ms
10,208 KB
testcase_03 AC 31 ms
10,208 KB
testcase_04 AC 30 ms
10,208 KB
testcase_05 AC 31 ms
10,208 KB
testcase_06 AC 30 ms
10,208 KB
testcase_07 AC 30 ms
10,208 KB
testcase_08 AC 30 ms
10,208 KB
testcase_09 AC 30 ms
10,208 KB
testcase_10 AC 31 ms
10,208 KB
testcase_11 AC 31 ms
10,208 KB
testcase_12 AC 30 ms
10,208 KB
testcase_13 AC 31 ms
10,208 KB
testcase_14 AC 30 ms
10,208 KB
testcase_15 AC 45 ms
10,256 KB
testcase_16 AC 37 ms
10,244 KB
testcase_17 AC 99 ms
10,300 KB
testcase_18 AC 184 ms
10,340 KB
testcase_19 AC 55 ms
10,268 KB
testcase_20 AC 55 ms
10,268 KB
testcase_21 AC 44 ms
10,256 KB
testcase_22 AC 152 ms
10,332 KB
testcase_23 AC 41 ms
10,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

for i in range(2,n+1):
    p = (i+2)//2
    get_p = 1
    use_m = 0
    tmp = []
    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
        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
    if m < use_m+p*2 or i==2:
        opposite()
    else:
        for j in range(p):
            for l in range(i-2,-1,-1):
                if lst[l]==1:
                    lst[l],tmp[l] = 2,2
                    use_m += 2
                    break
        lst = [m-use_m]+tmp[:]
print(*lst)
0