結果

問題 No.1965 Heavier
コンテスト
ユーザー ntuda
提出日時 2022-06-25 10:40:59
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 88 ms / 2,000 ms
+ 13µs
コード長 473 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 81,424 KB
実行使用メモリ 122,728 KB
最終ジャッジ日時 2026-09-22 01:51:47
合計ジャッジ時間 6,256 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = list(map(int, input().split())) + [0]
B = list(map(int, input().split())) + [0]
ans = 0
for i in range(N + 1):
    if i == 0:
        nowa = A[i] + B[i]
        nowb = A[i] - B[i]
        cnt = 1
    else:
        nexta = A[i] + B[i]
        nextb = A[i] - B[i]
        if nowa < nexta and nowb < nextb:
            cnt += 1
        else:
            ans += (cnt - 1) * cnt // 2
            cnt = 1
        nowa = nexta
        nowb = nextb
print(ans)
0