結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
85,132 KB
testcase_01 AC 114 ms
85,080 KB
testcase_02 AC 115 ms
85,268 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 117 ms
85,200 KB
testcase_06 AC 223 ms
126,308 KB
testcase_07 AC 225 ms
126,604 KB
testcase_08 AC 218 ms
131,160 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 205 ms
126,348 KB
testcase_26 AC 203 ms
128,124 KB
testcase_27 AC 210 ms
127,468 KB
testcase_28 AC 211 ms
127,344 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 = 1

ans = 0

while i < N:
    while 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:
            break
        j += 1
    if j <= i:
        j += 1
    else:
        i += 1

print(ans)

























0