結果

問題 No.2053 12345...
ユーザー ntudantuda
提出日時 2022-10-06 21:06:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 213 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 29,940 KB
最終ジャッジ日時 2023-09-02 01:29:32
合計ジャッジ時間 5,307 ms
ジャッジサーバーID
(参考情報)
judge16 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,892 KB
testcase_01 AC 15 ms
7,800 KB
testcase_02 AC 17 ms
8,212 KB
testcase_03 AC 46 ms
12,932 KB
testcase_04 AC 92 ms
22,940 KB
testcase_05 AC 32 ms
11,236 KB
testcase_06 AC 84 ms
21,052 KB
testcase_07 AC 64 ms
17,240 KB
testcase_08 AC 60 ms
16,636 KB
testcase_09 AC 94 ms
22,964 KB
testcase_10 AC 124 ms
28,276 KB
testcase_11 AC 31 ms
10,744 KB
testcase_12 AC 25 ms
9,776 KB
testcase_13 AC 127 ms
27,356 KB
testcase_14 AC 51 ms
14,036 KB
testcase_15 AC 44 ms
13,460 KB
testcase_16 AC 45 ms
12,988 KB
testcase_17 AC 36 ms
11,328 KB
testcase_18 AC 138 ms
29,600 KB
testcase_19 AC 95 ms
23,780 KB
testcase_20 AC 23 ms
9,616 KB
testcase_21 AC 70 ms
17,168 KB
testcase_22 AC 17 ms
8,328 KB
testcase_23 AC 27 ms
10,428 KB
testcase_24 AC 44 ms
13,552 KB
testcase_25 AC 116 ms
27,492 KB
testcase_26 AC 64 ms
17,288 KB
testcase_27 AC 43 ms
13,424 KB
testcase_28 AC 37 ms
12,224 KB
testcase_29 AC 82 ms
20,848 KB
testcase_30 AC 41 ms
12,828 KB
testcase_31 AC 79 ms
20,156 KB
testcase_32 AC 138 ms
29,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split())) + [0]
ans = 0
cnt = 0
for i in range(N):
    if A[i] + 1 == A[i + 1]:
        cnt += 1
    else:
        ans += cnt * (cnt + 1) // 2
        cnt = 0
print(ans)
0