結果

問題 No.2142 Segment Zero
ユーザー titiatitia
提出日時 2022-12-02 22:14:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 86,656 KB
最終ジャッジ日時 2024-04-18 06:32:28
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,584 KB
testcase_01 AC 83 ms
84,096 KB
testcase_02 AC 36 ms
51,712 KB
testcase_03 AC 90 ms
84,096 KB
testcase_04 AC 107 ms
85,760 KB
testcase_05 AC 74 ms
85,376 KB
testcase_06 AC 35 ms
51,968 KB
testcase_07 WA -
testcase_08 AC 76 ms
85,376 KB
testcase_09 WA -
testcase_10 AC 76 ms
84,992 KB
testcase_11 AC 76 ms
85,760 KB
testcase_12 AC 82 ms
86,272 KB
testcase_13 AC 81 ms
86,656 KB
testcase_14 AC 76 ms
85,760 KB
testcase_15 AC 83 ms
86,144 KB
testcase_16 AC 75 ms
85,120 KB
testcase_17 AC 71 ms
81,536 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 61 ms
73,344 KB
testcase_21 WA -
testcase_22 AC 67 ms
78,208 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 61 ms
73,600 KB
testcase_29 AC 63 ms
75,136 KB
testcase_30 AC 67 ms
78,464 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 83 ms
85,632 KB
testcase_36 AC 57 ms
67,456 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)

A=[0]*N

x=K

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