結果

問題 No.1965 Heavier
ユーザー TsubajiroTsubajiro
提出日時 2022-07-02 19:35:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 410 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 39,560 KB
最終ジャッジ日時 2023-08-18 11:31:31
合計ジャッジ時間 11,611 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,772 KB
testcase_01 AC 16 ms
7,852 KB
testcase_02 AC 15 ms
7,864 KB
testcase_03 AC 16 ms
7,792 KB
testcase_04 AC 16 ms
7,852 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 374 ms
39,540 KB
testcase_07 AC 368 ms
39,376 KB
testcase_08 AC 365 ms
39,560 KB
testcase_09 AC 369 ms
38,456 KB
testcase_10 AC 375 ms
38,340 KB
testcase_11 AC 379 ms
38,372 KB
testcase_12 AC 15 ms
7,864 KB
testcase_13 AC 15 ms
7,784 KB
testcase_14 AC 14 ms
7,928 KB
testcase_15 AC 400 ms
39,532 KB
testcase_16 AC 398 ms
39,468 KB
testcase_17 AC 286 ms
29,340 KB
testcase_18 AC 406 ms
39,172 KB
testcase_19 AC 410 ms
39,484 KB
testcase_20 AC 410 ms
39,092 KB
testcase_21 AC 378 ms
37,232 KB
testcase_22 AC 357 ms
35,428 KB
testcase_23 AC 249 ms
27,156 KB
testcase_24 AC 314 ms
32,580 KB
testcase_25 AC 363 ms
39,228 KB
testcase_26 AC 369 ms
38,928 KB
testcase_27 AC 382 ms
38,740 KB
testcase_28 AC 385 ms
38,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans=0
C = []
for i in range(N-1):
    if A[i]+max(B[i],B[i+1])<A[i+1]+min(B[i],B[i+1]):
        C.append(1)
    else:
        C.append(0)

left=0
#print(C)
while left<=N-2:
    count=0
    if C[left]==0:
        left+=1
        continue
    for right in range(left,N-1):
        if C[right]==1:
            count+=1
        else:
            break
    left+=count
    ans+=(count+1)*count//2
print(ans)
0