結果

問題 No.625 ソンタクロース
ユーザー maspy
提出日時 2020-03-18 19:13:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 167 ms / 4,000 ms
コード長 522 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-12-14 02:24:28
合計ジャッジ時間 2,417 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter

N, M = map(int, read().split())


A = [M]
for _ in range(N - 1):
    AA = sorted(enumerate(A), key=itemgetter(1))
    n = (len(A) + 1) // 2
    B = [0] * (len(A) + 1)
    S = 0
    for i, x in AA[:n]:
        x += 1
        B[i] = x
        S += x
    B[-1] = M - S
    if B[-1] < 0:
        B = A[:]
        B.append(-1)
    A = B
print(*A[::-1])
0