結果

問題 No.2142 Segment Zero
ユーザー titiatitia
提出日時 2022-12-02 22:08:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 556 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,568 KB
最終ジャッジ日時 2024-04-18 06:10:32
合計ジャッジ時間 4,151 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 81 ms
74,624 KB
testcase_02 AC 43 ms
51,840 KB
testcase_03 AC 80 ms
75,520 KB
testcase_04 AC 86 ms
76,544 KB
testcase_05 AC 85 ms
76,544 KB
testcase_06 AC 43 ms
51,840 KB
testcase_07 WA -
testcase_08 AC 80 ms
76,160 KB
testcase_09 WA -
testcase_10 AC 80 ms
76,288 KB
testcase_11 AC 80 ms
76,416 KB
testcase_12 AC 87 ms
77,184 KB
testcase_13 AC 88 ms
77,568 KB
testcase_14 AC 79 ms
76,416 KB
testcase_15 AC 86 ms
77,184 KB
testcase_16 AC 81 ms
76,416 KB
testcase_17 AC 75 ms
73,600 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 63 ms
67,840 KB
testcase_21 WA -
testcase_22 AC 72 ms
71,040 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 71 ms
67,712 KB
testcase_29 AC 69 ms
69,248 KB
testcase_30 AC 74 ms
71,936 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 86 ms
76,928 KB
testcase_36 AC 60 ms
64,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())

ANS=N

A=[0]*N

x=K
for i in range(N,0,-1):
    if x>=i:
        A[i-1]=1
        x-=i


count=0
for i in range(N):
    if A[i]==0 and (i==0 or A[i-1]==1):
        count+=1

ANS=min(ANS,count)


A=[0]*N

x=K
for i in range(N,0,-1):
    if x>=i:
        A[i-1]=1
        x-=i
    else:
        break

for i in range(1,N+1):
    if x>=i and A[i-1]==0:
        A[i-1]=1
        x-=i

if x==0:
    count=0
    for i in range(N):
        if A[i]==0 and (i==0 or A[i-1]==1):
            count+=1

    ANS=min(ANS,count)

print(ANS)
0