結果

問題 No.1965 Heavier
ユーザー chineristACchineristAC
提出日時 2022-06-03 22:56:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 137,128 KB
最終ジャッジ日時 2023-10-21 02:15:40
合計ジャッジ時間 6,873 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
56,092 KB
testcase_01 AC 50 ms
56,092 KB
testcase_02 AC 52 ms
56,092 KB
testcase_03 AC 49 ms
56,092 KB
testcase_04 AC 52 ms
56,092 KB
testcase_05 AC 48 ms
56,092 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 228 ms
130,724 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 47 ms
56,092 KB
testcase_13 AC 48 ms
56,092 KB
testcase_14 AC 47 ms
56,092 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 221 ms
135,080 KB
testcase_26 AC 223 ms
134,704 KB
testcase_27 AC 195 ms
136,092 KB
testcase_28 AC 196 ms
136,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = int(input())
A = li()
B = li()

r = -1
M = []
del_M = []
m = []
del_m = []
res = 0
for l in range(N):
    if r==l-1:
        heappush(M,-(A[l]+B[l]))
        heappush(m,-(A[l]-B[l]))
        r = l
    while del_M and M[0]==del_M[0]:
        heappop(M)
        heappop(del_M)
    while del_m and m[0]==del_m[0]:
        heappop(m)
        heappop(del_m)
    while r!=N-1:
        if -M[0] < A[r+1]+B[r+1] and -m[0] < A[r+1]-B[r+1]:
            heappush(M,-(A[r+1]+B[r+1]))
            heappush(m,-(A[r+1]-B[r+1]))
            r += 1
        else:
            break
    
    res += r-l

print(res)

0