結果

問題 No.2142 Segment Zero
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-01-20 12:27:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 160,608 KB
最終ジャッジ日時 2023-09-05 06:21:25
合計ジャッジ時間 9,132 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
73,060 KB
testcase_01 AC 176 ms
160,500 KB
testcase_02 AC 113 ms
72,804 KB
testcase_03 AC 176 ms
160,332 KB
testcase_04 AC 327 ms
160,188 KB
testcase_05 AC 327 ms
160,580 KB
testcase_06 AC 112 ms
72,880 KB
testcase_07 AC 192 ms
160,228 KB
testcase_08 AC 188 ms
160,492 KB
testcase_09 AC 185 ms
160,148 KB
testcase_10 AC 197 ms
160,236 KB
testcase_11 AC 198 ms
160,200 KB
testcase_12 AC 187 ms
160,356 KB
testcase_13 AC 189 ms
160,160 KB
testcase_14 AC 197 ms
160,608 KB
testcase_15 AC 192 ms
160,560 KB
testcase_16 AC 196 ms
160,156 KB
testcase_17 AC 186 ms
151,112 KB
testcase_18 AC 137 ms
96,968 KB
testcase_19 AC 148 ms
94,500 KB
testcase_20 AC 161 ms
127,428 KB
testcase_21 AC 209 ms
133,672 KB
testcase_22 AC 169 ms
142,804 KB
testcase_23 AC 137 ms
94,548 KB
testcase_24 AC 144 ms
105,040 KB
testcase_25 AC 153 ms
112,184 KB
testcase_26 AC 175 ms
141,104 KB
testcase_27 AC 188 ms
141,988 KB
testcase_28 AC 158 ms
117,700 KB
testcase_29 AC 167 ms
127,352 KB
testcase_30 AC 177 ms
141,076 KB
testcase_31 AC 163 ms
140,884 KB
testcase_32 AC 160 ms
102,004 KB
testcase_33 AC 128 ms
88,856 KB
testcase_34 AC 155 ms
112,444 KB
testcase_35 AC 191 ms
159,884 KB
testcase_36 AC 148 ms
96,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import math,sys
input = sys.stdin.readline

N,K = map(int,input().split())
A = [i+1 for i in range(N)]
S = list(accumulate([0]+A))
if S[-1]==K:
    print(0)
    exit()
SN = N*(N+1)//2
for i in range(N):
    
    if S[-1]-S[i]<SN-K:
        break
    
    y = N
    x = i
    while y-x>1:
        mid = (y+x)//2
        
        if S[mid]-S[i]<SN-K:
            x = mid
        else:
            y = mid
    if S[y]-S[i]==SN-K:
        print(1)
        exit()
print(2)
0