結果

問題 No.625 ソンタクロース
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-07 13:55:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 165 ms / 4,000 ms
コード長 870 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 11,972 KB
実行使用メモリ 10,336 KB
最終ジャッジ日時 2023-10-19 22:25:58
合計ジャッジ時間 2,106 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,188 KB
testcase_01 AC 29 ms
10,188 KB
testcase_02 AC 29 ms
10,188 KB
testcase_03 AC 30 ms
10,188 KB
testcase_04 AC 29 ms
10,188 KB
testcase_05 AC 29 ms
10,188 KB
testcase_06 AC 29 ms
10,188 KB
testcase_07 AC 29 ms
10,188 KB
testcase_08 AC 30 ms
10,188 KB
testcase_09 AC 29 ms
10,188 KB
testcase_10 AC 29 ms
10,188 KB
testcase_11 AC 29 ms
10,188 KB
testcase_12 AC 29 ms
10,188 KB
testcase_13 AC 30 ms
10,188 KB
testcase_14 AC 31 ms
10,188 KB
testcase_15 AC 57 ms
10,252 KB
testcase_16 AC 44 ms
10,240 KB
testcase_17 AC 97 ms
10,296 KB
testcase_18 AC 165 ms
10,336 KB
testcase_19 AC 57 ms
10,264 KB
testcase_20 AC 60 ms
10,264 KB
testcase_21 AC 49 ms
10,252 KB
testcase_22 AC 153 ms
10,328 KB
testcase_23 AC 47 ms
10,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
santa = []

for i in range(1,N+1):
    point = i//2+1
    get_p = 1
    m = M
    tmp = santa[:]
    
    for j in range(len(santa)):
        if tmp[j]==-1:
            tmp[j]=0
            get_p+=1
        elif tmp[j]==0:
            tmp[j]=1
            get_p+=1
            m-=1
        else:
            tmp[j]=0
    
    num = 1
    while get_p<point:
        for j in range(len(tmp)-1,-1,-1):
            if tmp[j]==0 and santa[j]==num:
                tmp[j] = num+1
                m -= num+1
                get_p+=1
                break
        else:
            num+=1

    while get_p>point:
        for j in range(get_p-point):
            max_m = max(tmp)
            tmp[tmp.index(max_m)]=0
            get_p-=1
            m+=max_m
    if m<0:
        santa.insert(0,-1)
    else:
        santa = [m]+tmp[:]

print(*santa)
0