結果

問題 No.2142 Segment Zero
ユーザー tassei903tassei903
提出日時 2022-12-02 21:58:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,229 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 63,084 KB
最終ジャッジ日時 2024-04-18 05:53:14
合計ジャッジ時間 2,980 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 51 ms
59,136 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 43 ms
58,112 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 36 ms
52,352 KB
testcase_07 WA -
testcase_08 AC 52 ms
60,416 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 52 ms
60,800 KB
testcase_13 WA -
testcase_14 AC 52 ms
60,928 KB
testcase_15 AC 51 ms
60,672 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
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 WA -
testcase_28 AC 48 ms
61,184 KB
testcase_29 WA -
testcase_30 AC 49 ms
60,544 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 46 ms
60,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################
n, k = na()
K = k
ans = float("inf")
if k >= n:
    s = 1
    r = 0
    k -= n
    for i in range(n-1, 0, -1):
        if s == 1:
            if k >= i:
                k -= i
            else:
                s = 0
                r += 1
        else:
            if k <= i * (i - 1)//2:
                pass
            else:
                k -= i
                s = 1
                r += 1
    if s == 0:
        r += 1
    ans = r
k = K
if k <= n * (n - 1)//2:
    s = 0
    r = 1
    for i in range(n-1, 0, -1):
        #print(s)
        if s == 1:
            if k >= i:
                k -= i
            else:
                s = 0
                r += 1
        else:
            if k <= i * (i - 1)//2:
                pass
            else:
                k -= i
                s = 1
                r += 1
    if s == 0:
        r += 1

print(min(ans, r)//2)
0