結果

問題 No.2053 12345...
ユーザー lloyzlloyz
提出日時 2022-08-21 15:47:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 226 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 32,660 KB
最終ジャッジ日時 2024-04-18 13:01:04
合計ジャッジ時間 3,932 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 27 ms
10,624 KB
testcase_02 AC 29 ms
11,008 KB
testcase_03 AC 57 ms
15,584 KB
testcase_04 AC 107 ms
25,376 KB
testcase_05 AC 45 ms
13,712 KB
testcase_06 AC 106 ms
23,828 KB
testcase_07 AC 78 ms
19,800 KB
testcase_08 AC 76 ms
19,060 KB
testcase_09 AC 115 ms
25,572 KB
testcase_10 AC 135 ms
31,328 KB
testcase_11 AC 43 ms
13,524 KB
testcase_12 AC 39 ms
12,160 KB
testcase_13 AC 166 ms
30,388 KB
testcase_14 AC 80 ms
16,652 KB
testcase_15 AC 61 ms
15,852 KB
testcase_16 AC 70 ms
15,620 KB
testcase_17 AC 59 ms
14,112 KB
testcase_18 AC 192 ms
32,268 KB
testcase_19 AC 118 ms
26,124 KB
testcase_20 AC 39 ms
12,032 KB
testcase_21 AC 106 ms
19,728 KB
testcase_22 AC 29 ms
11,008 KB
testcase_23 AC 40 ms
12,844 KB
testcase_24 AC 59 ms
16,080 KB
testcase_25 AC 138 ms
30,120 KB
testcase_26 AC 81 ms
19,860 KB
testcase_27 AC 59 ms
16,204 KB
testcase_28 AC 54 ms
14,768 KB
testcase_29 AC 97 ms
23,408 KB
testcase_30 AC 56 ms
15,480 KB
testcase_31 AC 96 ms
22,748 KB
testcase_32 AC 144 ms
32,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))

ans = 0
l, r = 0, 1
while l < n - 1:
    while r < n and A[r] - A[r - 1] == 1:
        r += 1
    m = r - l
    ans += m * (m - 1) // 2
    r += 1
    l = r - 1
print(ans)
0