結果
| 問題 | No.1965 Heavier |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-07-19 17:14:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 712 bytes |
| 記録 | |
| コンパイル時間 | 1,186 ms |
| コンパイル使用メモリ | 95,976 KB |
| 実行使用メモリ | 144,716 KB |
| 最終ジャッジ日時 | 2026-07-19 17:14:53 |
| 合計ジャッジ時間 | 8,171 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 15 |
ソースコード
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