結果

問題 No.1965 Heavier
ユーザー ntudantuda
提出日時 2022-06-25 10:40:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 137,248 KB
最終ジャッジ日時 2024-04-26 16:44:46
合計ジャッジ時間 4,973 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 AC 37 ms
52,096 KB
testcase_02 AC 36 ms
52,024 KB
testcase_03 AC 38 ms
52,096 KB
testcase_04 AC 36 ms
52,096 KB
testcase_05 AC 37 ms
51,968 KB
testcase_06 AC 151 ms
136,344 KB
testcase_07 AC 145 ms
136,348 KB
testcase_08 AC 126 ms
112,232 KB
testcase_09 AC 146 ms
137,016 KB
testcase_10 AC 142 ms
136,752 KB
testcase_11 AC 141 ms
137,120 KB
testcase_12 AC 37 ms
52,316 KB
testcase_13 AC 37 ms
52,096 KB
testcase_14 AC 38 ms
52,080 KB
testcase_15 AC 143 ms
136,464 KB
testcase_16 AC 145 ms
136,360 KB
testcase_17 AC 110 ms
102,244 KB
testcase_18 AC 147 ms
136,376 KB
testcase_19 AC 133 ms
111,644 KB
testcase_20 AC 145 ms
136,172 KB
testcase_21 AC 127 ms
107,900 KB
testcase_22 AC 127 ms
108,364 KB
testcase_23 AC 104 ms
100,124 KB
testcase_24 AC 118 ms
103,956 KB
testcase_25 AC 138 ms
135,488 KB
testcase_26 AC 135 ms
134,836 KB
testcase_27 AC 140 ms
137,164 KB
testcase_28 AC 141 ms
137,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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