結果
問題 | No.871 かえるのうた |
ユーザー |
|
提出日時 | 2019-08-31 09:56:29 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 82,636 KB |
実行使用メモリ | 96,804 KB |
最終ジャッジ日時 | 2024-11-30 10:53:39 |
合計ジャッジ時間 | 4,299 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
import sys input = sys.stdin.readline N, K = map(int, input().split()) K -= 1 X = list(map(int, input().split())) A = list(map(int, input().split())) l, r = K, K ld, rd = X[K] - A[K], X[K] + A[K] update = True while update: update = False if l - 1 >= 0 and ld <= X[l-1]: update = True l -= 1 ld = min(ld, X[l] - A[l]) rd = max(rd, X[l] + A[l]) if r + 1 < N and X[r+1] <= rd: update = True r += 1 rd = max(rd, X[r] + A[r]) ld = min(ld, X[r] - A[r]) print(r - l + 1)