結果

問題 No.2142 Segment Zero
ユーザー ShirotsumeShirotsume
提出日時 2022-12-05 01:35:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 72,304 KB
最終ジャッジ日時 2024-04-20 06:19:56
合計ジャッジ時間 3,789 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,800 KB
testcase_01 AC 54 ms
70,016 KB
testcase_02 AC 36 ms
53,504 KB
testcase_03 AC 63 ms
68,224 KB
testcase_04 AC 79 ms
70,656 KB
testcase_05 AC 83 ms
70,656 KB
testcase_06 AC 48 ms
53,888 KB
testcase_07 AC 69 ms
72,184 KB
testcase_08 AC 60 ms
70,400 KB
testcase_09 AC 81 ms
72,304 KB
testcase_10 AC 63 ms
70,784 KB
testcase_11 AC 62 ms
70,400 KB
testcase_12 AC 64 ms
70,400 KB
testcase_13 AC 60 ms
70,656 KB
testcase_14 AC 60 ms
70,400 KB
testcase_15 AC 61 ms
70,656 KB
testcase_16 AC 61 ms
70,656 KB
testcase_17 AC 60 ms
68,992 KB
testcase_18 AC 52 ms
64,640 KB
testcase_19 AC 56 ms
66,560 KB
testcase_20 AC 65 ms
67,200 KB
testcase_21 AC 82 ms
69,504 KB
testcase_22 AC 65 ms
67,840 KB
testcase_23 AC 54 ms
65,024 KB
testcase_24 AC 56 ms
66,560 KB
testcase_25 AC 67 ms
66,944 KB
testcase_26 AC 65 ms
69,504 KB
testcase_27 AC 59 ms
70,144 KB
testcase_28 AC 54 ms
66,432 KB
testcase_29 AC 53 ms
67,072 KB
testcase_30 AC 61 ms
68,352 KB
testcase_31 AC 58 ms
68,864 KB
testcase_32 AC 55 ms
67,072 KB
testcase_33 AC 47 ms
63,488 KB
testcase_34 AC 55 ms
67,968 KB
testcase_35 AC 60 ms
70,016 KB
testcase_36 AC 50 ms
64,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
sys.setrecursionlimit(5 * 10 ** 5)
from pypyjit import set_param
set_param('max_unroll_recursion=-1')
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353

n, k = mi()

a = list(range(1, n + 1))

k = sum(a) - k

right = 0
#n -> 数列の長さ
s = 0
ans = 2
for left in range(n):
    while right < n:
        s += a[right]
        if s <= k:
            right += 1
        else:
            s -= a[right]
            break

    if s == k:
        ans = 1

    if right == left:
        right += 1
    else:
        s -= a[left]
print(ans)
0