結果

問題 No.871 かえるのうた
ユーザー FromBooskaFromBooska
提出日時 2023-02-27 15:40:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,248 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 103,832 KB
最終ジャッジ日時 2023-10-13 01:02:32
合計ジャッジ時間 10,347 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,656 KB
testcase_01 AC 76 ms
71,396 KB
testcase_02 AC 73 ms
71,292 KB
testcase_03 AC 73 ms
71,320 KB
testcase_04 AC 75 ms
71,312 KB
testcase_05 AC 74 ms
71,404 KB
testcase_06 AC 72 ms
71,132 KB
testcase_07 AC 73 ms
71,288 KB
testcase_08 AC 84 ms
76,192 KB
testcase_09 AC 82 ms
76,460 KB
testcase_10 AC 91 ms
76,640 KB
testcase_11 AC 78 ms
75,644 KB
testcase_12 AC 93 ms
80,008 KB
testcase_13 AC 86 ms
76,548 KB
testcase_14 AC 130 ms
100,932 KB
testcase_15 AC 135 ms
101,880 KB
testcase_16 AC 247 ms
103,832 KB
testcase_17 AC 125 ms
97,896 KB
testcase_18 AC 83 ms
79,764 KB
testcase_19 AC 154 ms
103,608 KB
testcase_20 AC 97 ms
78,032 KB
testcase_21 AC 144 ms
89,192 KB
testcase_22 AC 72 ms
71,512 KB
testcase_23 AC 73 ms
71,544 KB
testcase_24 AC 72 ms
71,424 KB
testcase_25 AC 95 ms
76,580 KB
testcase_26 AC 117 ms
77,796 KB
testcase_27 AC 86 ms
77,628 KB
testcase_28 AC 73 ms
71,468 KB
testcase_29 AC 106 ms
97,388 KB
testcase_30 AC 241 ms
96,116 KB
testcase_31 AC 77 ms
75,724 KB
testcase_32 AC 230 ms
96,884 KB
testcase_33 AC 135 ms
97,832 KB
testcase_34 AC 84 ms
81,980 KB
testcase_35 AC 116 ms
97,508 KB
testcase_36 AC 115 ms
96,112 KB
testcase_37 AC 216 ms
91,736 KB
testcase_38 AC 353 ms
98,880 KB
testcase_39 AC 276 ms
97,496 KB
testcase_40 TLE -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# deque案TLEした
# TLEするのはAが大きくて、あまりに多くの点をチェック、appendするからだろう
# その問題はグラフ化でも変わらない、辺が増えすぎる
# 大事なのは左端と右端だけではないか、左端と右端がわかればいい
# 更新のときも左端か右端をどれだけ超えるのかだけが重要
# 範囲が増えた時だけ、その増えた範囲から、さらに範囲が増えるかチェック
# visitedではなく右端引く左端が答え

N, K = map(int, input().split())
INF = 10**20
X = [-INF]+list(map(int, input().split()))+[INF]
A = [0]+list(map(int, input().split()))+[0]

from bisect import *

rng = (K, K)
visited = [0]*(N+1)

while True:
    #print('pre', rng)
    left, right = rng
    for i in range(left, right+1):
        if visited[i] == 0:
            visited[i] = 1
            lower = bisect_left(X, X[i]-A[i])
            upper = bisect_left(X, X[i]+A[i])
            if X[upper] != X[i]+A[i]:
                upper -= 1
            left = min(left, lower)
            right = max(right, upper)
    if (left, right) == rng:
        break
    else:
        rng = (left, right)
    #print('post', rng)
    
ans = right+1-left
print(ans)




0