結果

問題 No.2053 12345...
ユーザー shinichishinichi
提出日時 2022-08-27 00:47:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 209 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 104,320 KB
最終ジャッジ日時 2024-04-22 02:41:12
合計ジャッジ時間 3,744 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,712 KB
testcase_01 AC 32 ms
51,712 KB
testcase_02 AC 41 ms
59,136 KB
testcase_03 AC 44 ms
68,992 KB
testcase_04 AC 64 ms
92,928 KB
testcase_05 AC 41 ms
66,048 KB
testcase_06 AC 61 ms
88,832 KB
testcase_07 AC 57 ms
80,128 KB
testcase_08 AC 52 ms
77,952 KB
testcase_09 AC 63 ms
93,184 KB
testcase_10 AC 78 ms
104,320 KB
testcase_11 AC 42 ms
65,408 KB
testcase_12 AC 44 ms
65,408 KB
testcase_13 AC 81 ms
104,068 KB
testcase_14 AC 59 ms
74,624 KB
testcase_15 AC 50 ms
73,216 KB
testcase_16 AC 53 ms
73,984 KB
testcase_17 AC 49 ms
70,144 KB
testcase_18 AC 90 ms
101,888 KB
testcase_19 AC 67 ms
94,720 KB
testcase_20 AC 46 ms
65,536 KB
testcase_21 AC 61 ms
82,816 KB
testcase_22 AC 35 ms
58,624 KB
testcase_23 AC 40 ms
63,872 KB
testcase_24 AC 45 ms
70,144 KB
testcase_25 AC 72 ms
102,016 KB
testcase_26 AC 53 ms
79,616 KB
testcase_27 AC 45 ms
70,784 KB
testcase_28 AC 42 ms
67,968 KB
testcase_29 AC 59 ms
86,528 KB
testcase_30 AC 44 ms
68,992 KB
testcase_31 AC 57 ms
85,504 KB
testcase_32 AC 88 ms
102,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

print(ans)
0