結果

問題 No.2142 Segment Zero
ユーザー MasKoaTSMasKoaTS
提出日時 2022-12-02 22:40:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 286 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 59,588 KB
最終ジャッジ日時 2024-04-18 07:32:13
合計ジャッジ時間 2,786 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,072 KB
testcase_01 AC 42 ms
57,704 KB
testcase_02 AC 35 ms
52,388 KB
testcase_03 AC 35 ms
52,668 KB
testcase_04 AC 48 ms
59,588 KB
testcase_05 AC 49 ms
57,984 KB
testcase_06 AC 34 ms
52,372 KB
testcase_07 AC 40 ms
58,448 KB
testcase_08 AC 42 ms
58,176 KB
testcase_09 AC 42 ms
59,052 KB
testcase_10 AC 44 ms
58,372 KB
testcase_11 AC 43 ms
58,516 KB
testcase_12 AC 44 ms
58,844 KB
testcase_13 AC 44 ms
58,236 KB
testcase_14 AC 44 ms
58,504 KB
testcase_15 AC 44 ms
59,188 KB
testcase_16 AC 43 ms
58,828 KB
testcase_17 AC 46 ms
58,720 KB
testcase_18 AC 41 ms
58,052 KB
testcase_19 AC 41 ms
59,004 KB
testcase_20 AC 42 ms
58,280 KB
testcase_21 AC 45 ms
58,180 KB
testcase_22 AC 42 ms
58,048 KB
testcase_23 AC 40 ms
58,268 KB
testcase_24 AC 42 ms
57,984 KB
testcase_25 AC 41 ms
58,776 KB
testcase_26 AC 42 ms
59,396 KB
testcase_27 AC 42 ms
59,044 KB
testcase_28 AC 42 ms
58,732 KB
testcase_29 AC 43 ms
58,256 KB
testcase_30 AC 39 ms
59,104 KB
testcase_31 AC 41 ms
58,256 KB
testcase_32 AC 42 ms
58,388 KB
testcase_33 AC 35 ms
57,584 KB
testcase_34 AC 36 ms
58,648 KB
testcase_35 AC 41 ms
58,052 KB
testcase_36 AC 42 ms
58,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, m = map(int, input().split())

t = n * (n + 1) // 2 - m
if(t == 0):
	print(0)
	exit(0)

l = r = 1
s = 0
while(True):
	if(s == t):
		print(1)
		exit(0)
	elif(s < t):
		if(r > n):
			print(2)
			exit(0)
		s += r
		r += 1
	else:
		s -= l
		l += 1
0