結果

問題 No.1965 Heavier
ユーザー buey_tbuey_t
提出日時 2023-08-08 22:26:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,578 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 132,828 KB
最終ジャッジ日時 2024-04-26 14:36:44
合計ジャッジ時間 7,314 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
85,268 KB
testcase_01 AC 117 ms
85,000 KB
testcase_02 AC 116 ms
84,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 119 ms
84,956 KB
testcase_06 AC 226 ms
126,412 KB
testcase_07 AC 221 ms
126,492 KB
testcase_08 AC 215 ms
131,444 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
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 202 ms
126,816 KB
testcase_26 AC 205 ms
127,924 KB
testcase_27 AC 209 ms
127,468 KB
testcase_28 AC 214 ms
127,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
from heapq import heapify, heappop, heappush
from bisect import bisect_left, bisect_right
from copy import deepcopy
import copy
import random
from random import randrange
from collections import deque,Counter,defaultdict
from itertools import permutations,combinations
from decimal import Decimal,ROUND_HALF_UP
#tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
from functools import lru_cache, reduce
#@lru_cache(maxsize=None)
from operator import add,sub,mul,xor,and_,or_,itemgetter
import sys
#input = sys.stdin.readline
# .rstrip()
INF = 10**18
mod1 = 10**9+7
mod2 = 998244353

#DecimalならPython
#再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!


'''
Bi < Bj
交換した結果、逆転するといくない
荷物が重いといくない
今までの区間で一番大きい値を持っておく
荷物が軽いほうが良い
体重は重いほうがよくて、荷物は軽いほうがいい
体重-荷物がでかいやつ
二分探索が必要か?
単調増加

2 4 5 8
2 1 6 2

[1,2],[3,4]

右のほうがでかくなるはずなんだよな
絶対に
ただの尺取じゃね

'''

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

i = 0
j = 0

ans = 0

while i < N and j < N:
    b1 = max(B[i],B[j])
    b2 = min(B[i],B[j])
    
    if A[i]+b1 < A[j]+b2:
        ans += j-i
    else:
        if i==j:
            j += 1
        else:
            i += 1
        continue
    j += 1

print(ans)

























0