結果
問題 | No.871 かえるのうた |
ユーザー | anagohirame |
提出日時 | 2019-08-30 22:59:44 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 243 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 129 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 28,936 KB |
最終ジャッジ日時 | 2024-11-30 10:49:51 |
合計ジャッジ時間 | 4,875 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
n, k = map(int, input().split()) x = list(map(int, input().split())) a = list(map(int, input().split())) left = list(range(k-1)) right = list(range(n-1, k-1, -1)) lm, rm = x[k-1]-a[k-1], x[k-1]+a[k-1] while True: left_ok, right_ok = False, False if left != [] and x[left[-1]] >= lm: left_ok = True lm = min(lm, x[left[-1]]-a[left[-1]]) rm = max(rm, x[left[-1]]+a[left[-1]]) left.pop() if right != [] and x[right[-1]] <= rm: right_ok = True lm = min(lm, x[right[-1]]-a[right[-1]]) rm = max(rm, x[right[-1]]+a[right[-1]]) right.pop() if not left_ok and not right_ok: break print(n-len(left)-len(right))