結果
| 問題 | No.1965 Heavier |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-07-19 17:38:25 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 413 ms / 2,000 ms |
| + 832µs | |
| コード長 | 714 bytes |
| 記録 | |
| コンパイル時間 | 1,492 ms |
| コンパイル使用メモリ | 95,216 KB |
| 実行使用メモリ | 133,324 KB |
| 最終ジャッジ日時 | 2026-07-19 17:39:08 |
| 合計ジャッジ時間 | 9,278 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
from heapq import *
def main():
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
r = 0
ans = 0
hq0 = []
hq0_ = []
hq1 = []
hq1_ = []
for l in range(n):
while l == r or (r < n and hq0[0] > -A[r]-B[r] and hq1[0] > -A[r]+B[r]):
heappush(hq0, -A[r]-B[r])
heappush(hq1, -A[r]+B[r])
r += 1
ans += r-l-1
heappush(hq0_, -A[l]-B[l])
heappush(hq1_, -A[l]+B[l])
while hq0_ and hq0[0] == hq0_[0]:
heappop(hq0)
heappop(hq0_)
while hq1_ and hq1[0] == hq1_[0]:
heappop(hq1)
heappop(hq1_)
return ans
print(main())
kidodesu