提出 #70098394


ソースコード 拡げる

import sys
input = sys.stdin.readline

for _ in range(int(input())):
    N, K = map(int, input().split())
    
    ans = K * 2 + 1
    left, right = 1, K * 2
    while left <= right:
        mid = (left + right) // 2
        A = []
        A.append(mid)
        mods = K
        for i in range(N - 1):
            next = (A[-1] + 1) // 2
            if next * 2 == A[-1]:
                next += 1
            if next == 0:
                mods = 10 ** 9
                break
            if A[-1] - next >= mods:
                A.append(A[-1] - mods)
                mods = 0
            else:
                A.append(next)
                mods -= A[-2] - A[-1]
        
        if mods == 0:
            ans = min(ans, mid)
            right = mid - 1
        else:
            left = mid + 1
    A = []
    A.append(ans)
    mods = K
    for i in range(N - 1):
        next = (A[-1] + 1) // 2
        if next * 2 == A[-1]:
            next += 1
        if next == 0:
            mods = 10 ** 9
            break
        if A[-1] - next >= mods:
            A.append(A[-1] - mods)
            mods = 0
        else:
            A.append(next)
            mods -= A[-2] - A[-1]
    print(*A[::-1])

提出情報

提出日時
問題 B - Sum of Mod
ユーザ fermion5
言語 Python (PyPy 3.10-v7.3.12)
得点 600
コード長 1248 Byte
結果 AC
実行時間 277 ms
メモリ 299544 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 600 / 600
結果
AC × 1
AC × 26
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 57 ms 76344 KiB
01_handmade_00.txt AC 161 ms 84348 KiB
01_handmade_01.txt AC 164 ms 84132 KiB
01_handmade_02.txt AC 102 ms 129368 KiB
01_handmade_03.txt AC 110 ms 143116 KiB
01_handmade_04.txt AC 277 ms 299544 KiB
01_handmade_05.txt AC 277 ms 299136 KiB
01_handmade_06.txt AC 101 ms 129652 KiB
01_handmade_07.txt AC 109 ms 143160 KiB
01_handmade_08.txt AC 277 ms 299436 KiB
01_handmade_09.txt AC 277 ms 299096 KiB
01_handmade_10.txt AC 170 ms 86216 KiB
02_random_00.txt AC 157 ms 83904 KiB
02_random_01.txt AC 214 ms 84176 KiB
02_random_02.txt AC 195 ms 84416 KiB
02_random_03.txt AC 187 ms 83900 KiB
02_random_04.txt AC 182 ms 84260 KiB
02_random_05.txt AC 195 ms 84408 KiB
02_random_06.txt AC 117 ms 84104 KiB
02_random_07.txt AC 115 ms 84352 KiB
02_random_08.txt AC 161 ms 86328 KiB
02_random_09.txt AC 118 ms 84900 KiB
02_random_10.txt AC 120 ms 84888 KiB
02_random_11.txt AC 269 ms 298388 KiB
02_random_12.txt AC 203 ms 298380 KiB
02_random_13.txt AC 194 ms 298676 KiB