結果

問題 No.1965 Heavier
ユーザー 👑 rin204rin204
提出日時 2022-06-03 21:36:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 144,244 KB
最終ジャッジ日時 2023-10-21 01:40:36
合計ジャッジ時間 4,838 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,384 KB
testcase_01 AC 36 ms
53,384 KB
testcase_02 AC 35 ms
53,384 KB
testcase_03 AC 34 ms
53,384 KB
testcase_04 WA -
testcase_05 AC 35 ms
53,384 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 133 ms
122,516 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 143 ms
142,564 KB
testcase_26 AC 140 ms
141,976 KB
testcase_27 AC 142 ms
144,244 KB
testcase_28 AC 142 ms
144,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, A, B):
    C = [a - b for a, b in zip(A, B)]
    C.append(-1 << 30)
    ans = 0
    r = 0
    for l in range(n):
        if l == r:
            r += 1
        while C[r - 1] < C[r]:
            r += 1
        ans += r - l - 1
    return ans

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(solve(n, A, B))
exit()
def stupid(n, A, B):
    ans = 0
    for l in range(n):
        for r in range(l + 1, n):
            ok = True
            for ll in range(l, r + 1):
                for rr in range(ll + 1, r + 1):
                    if A[ll] + B[rr] >= A[rr] + B[ll]:
                        ok = False
                        break
                if not ok:
                    break
            ans += ok
    return ans

import random
random.seed(0)
for _ in range(100):
    n = 4
    A = random.sample(range(1, 6), k=n)
    A.sort()
    B = random.choices(range(1, 6), k=n)
    assert solve(n, A, B) == stupid(n, A, B), (n, A, B, solve(n, A, B), stupid(n, A, B))
0