結果

問題 No.2142 Segment Zero
ユーザー lloyzlloyz
提出日時 2023-01-04 00:05:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 438 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 241,476 KB
最終ジャッジ日時 2023-08-18 01:01:00
合計ジャッジ時間 9,049 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,072 KB
testcase_01 AC 310 ms
240,964 KB
testcase_02 AC 71 ms
71,352 KB
testcase_03 AC 72 ms
71,244 KB
testcase_04 AC 300 ms
241,252 KB
testcase_05 AC 272 ms
241,436 KB
testcase_06 AC 72 ms
71,076 KB
testcase_07 AC 121 ms
119,628 KB
testcase_08 AC 275 ms
241,392 KB
testcase_09 AC 178 ms
176,352 KB
testcase_10 AC 275 ms
241,468 KB
testcase_11 AC 281 ms
241,380 KB
testcase_12 AC 275 ms
241,476 KB
testcase_13 AC 277 ms
241,380 KB
testcase_14 AC 277 ms
241,144 KB
testcase_15 AC 278 ms
241,320 KB
testcase_16 AC 271 ms
241,356 KB
testcase_17 AC 250 ms
210,216 KB
testcase_18 AC 80 ms
79,620 KB
testcase_19 AC 97 ms
96,200 KB
testcase_20 AC 164 ms
165,828 KB
testcase_21 AC 148 ms
147,824 KB
testcase_22 AC 207 ms
196,720 KB
testcase_23 AC 108 ms
106,908 KB
testcase_24 AC 128 ms
124,632 KB
testcase_25 AC 109 ms
106,784 KB
testcase_26 AC 162 ms
156,972 KB
testcase_27 AC 122 ms
119,532 KB
testcase_28 AC 152 ms
148,656 KB
testcase_29 AC 168 ms
165,968 KB
testcase_30 AC 204 ms
196,456 KB
testcase_31 AC 78 ms
79,112 KB
testcase_32 AC 117 ms
114,704 KB
testcase_33 AC 94 ms
94,116 KB
testcase_34 AC 118 ms
114,684 KB
testcase_35 AC 275 ms
240,920 KB
testcase_36 AC 113 ms
110,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

s = n * (n + 1) // 2
# 総和から求める数を引いた差について見てる
dif = s - k
seen = set()
seen.add(0)
res = 0
for i in range(1, n + 1):
    res += i
    # 一部の総和からdifを引いた数がseenに含まれる場合は
    # その総和から後ろの方を除けばよいので1回となる
    if res - dif in seen:
        print(1)
        exit()
    seen.add(res)
print(2)
0