結果

問題 No.1635 Let’s Sort Integers!!
ユーザー 👑 rin204rin204
提出日時 2023-12-20 23:22:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 907 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 195,692 KB
最終ジャッジ日時 2023-12-20 23:22:23
合計ジャッジ時間 20,549 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 35 ms
53,460 KB
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 36 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 36 ms
53,460 KB
testcase_07 AC 36 ms
53,460 KB
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 36 ms
53,460 KB
testcase_12 AC 37 ms
53,460 KB
testcase_13 AC 36 ms
53,460 KB
testcase_14 AC 37 ms
53,460 KB
testcase_15 AC 37 ms
53,460 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 AC 36 ms
53,460 KB
testcase_18 AC 37 ms
53,460 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 36 ms
53,460 KB
testcase_28 AC 36 ms
53,460 KB
testcase_29 AC 36 ms
53,460 KB
testcase_30 AC 36 ms
53,460 KB
testcase_31 AC 37 ms
53,460 KB
testcase_32 AC 36 ms
53,460 KB
testcase_33 AC 38 ms
53,460 KB
testcase_34 AC 36 ms
53,460 KB
testcase_35 AC 37 ms
53,460 KB
testcase_36 AC 36 ms
53,460 KB
testcase_37 AC 36 ms
53,460 KB
testcase_38 AC 37 ms
53,460 KB
testcase_39 AC 36 ms
53,460 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 36 ms
53,460 KB
testcase_48 AC 38 ms
53,460 KB
testcase_49 AC 38 ms
53,460 KB
testcase_50 AC 37 ms
53,460 KB
testcase_51 AC 41 ms
59,068 KB
testcase_52 AC 38 ms
53,460 KB
testcase_53 AC 36 ms
53,460 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 36 ms
53,460 KB
testcase_60 AC 276 ms
195,692 KB
testcase_61 AC 259 ms
189,284 KB
testcase_62 AC 255 ms
181,212 KB
testcase_63 AC 262 ms
192,336 KB
testcase_64 AC 262 ms
190,224 KB
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 AC 36 ms
53,460 KB
testcase_69 AC 36 ms
53,460 KB
testcase_70 AC 237 ms
195,692 KB
testcase_71 AC 254 ms
187,296 KB
testcase_72 AC 249 ms
186,896 KB
testcase_73 AC 250 ms
186,240 KB
testcase_74 AC 270 ms
188,784 KB
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 38 ms
53,460 KB
testcase_79 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
if k < n - 1:
    print(-1)
    exit()

ma = n * (n - 1) // 2
if k > ma:
    print(-1)
    exit()

K = k
P = []
P = [n]
l = 2
r = n - 1
k -= n - 1
used = [False] * (n + 1)
used[n] = True
while k > 0:
    if len(P) % 2 == 1:
        d = P[-1] - l
        if d >= k:
            used[P[-1] - k] = True
            P.append(P[-1] - k)
            k = 0
        else:
            used[l] = True
            P.append(l)
            l += 1
            k -= d
    else:
        d = r - P[-1]
        if d >= k:
            used[P[-1] + k] = True
            P.append(P[-1] + k)
            k = 0
        else:
            used[r] = True
            P.append(r)
            r -= 1
            k -= d

L = []
for i in range(1, n + 1):
    if not used[i]:
        L.append(i)
ans = L + P
print(*ans)

tot = 0
for i in range(n - 1):
    tot += abs(ans[i] - ans[i + 1])
assert tot == K
0