結果
| 問題 |
No.871 かえるのうた
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2025-10-15 03:52:25 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 122 ms / 2,000 ms |
| コード長 | 722 bytes |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 99,232 KB |
| 最終ジャッジ日時 | 2025-10-15 03:52:32 |
| 合計ジャッジ時間 | 6,635 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 49 |
ソースコード
"""
https://yukicoder.me/problems/no/871
範囲が区間になるのを活用するはず
"""
N,K = map(int,input().split())
X = list(map(int,input().split()))
A = list(map(int,input().split()))
L = [ (X[i],A[i]) for i in range(K-1) ]
R = [ (X[i],A[i]) for i in range(K,N) ]
R.reverse()
now = [ X[K-1] - A[K-1] , X[K-1] + A[K-1] ]
flag = True
while flag:
flag = False
if L and now[0] <= L[-1][0] <= now[1]:
x,a = L.pop()
now[0] = min(now[0], x-a)
now[1] = max(now[1], x+a)
flag = True
if R and now[0] <= R[-1][0] <= now[1]:
x,a = R.pop()
now[0] = min(now[0], x-a)
now[1] = max(now[1], x+a)
flag = True
print (N - len(L) - len(R))
SPD_9X2