結果

問題 No.2053 12345...
ユーザー H3PO4H3PO4
提出日時 2022-08-21 12:56:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 32,668 KB
最終ジャッジ日時 2024-04-18 12:43:44
合計ジャッジ時間 4,153 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
11,008 KB
testcase_03 AC 58 ms
15,468 KB
testcase_04 AC 122 ms
25,512 KB
testcase_05 AC 50 ms
14,100 KB
testcase_06 AC 110 ms
24,060 KB
testcase_07 AC 85 ms
19,932 KB
testcase_08 AC 81 ms
19,200 KB
testcase_09 AC 117 ms
25,580 KB
testcase_10 AC 148 ms
31,336 KB
testcase_11 AC 47 ms
13,784 KB
testcase_12 AC 41 ms
12,404 KB
testcase_13 AC 152 ms
30,528 KB
testcase_14 AC 70 ms
16,536 KB
testcase_15 AC 62 ms
15,988 KB
testcase_16 AC 63 ms
15,632 KB
testcase_17 AC 53 ms
14,252 KB
testcase_18 AC 167 ms
32,280 KB
testcase_19 AC 120 ms
26,256 KB
testcase_20 AC 37 ms
12,160 KB
testcase_21 AC 94 ms
19,864 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 43 ms
12,984 KB
testcase_24 AC 63 ms
16,256 KB
testcase_25 AC 146 ms
30,120 KB
testcase_26 AC 83 ms
19,988 KB
testcase_27 AC 61 ms
16,088 KB
testcase_28 AC 56 ms
15,032 KB
testcase_29 AC 104 ms
23,408 KB
testcase_30 AC 58 ms
15,360 KB
testcase_31 AC 101 ms
22,960 KB
testcase_32 AC 159 ms
32,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

INF = 10 ** 9 + 7
A = [INF] + A + [INF]

ans = 0
ct = 0
for i in range(N + 1):
    if A[i + 1] - A[i] == 1:
        ct += 1
    else:
        ans += ct * (ct + 1) // 2
        ct = 0
print(ans)
0