結果

問題 No.2053 12345...
ユーザー Akijin_007Akijin_007
提出日時 2022-10-17 17:46:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 223 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 100,456 KB
最終ジャッジ日時 2023-09-10 16:51:08
合計ジャッジ時間 6,716 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,296 KB
testcase_01 AC 69 ms
70,996 KB
testcase_02 AC 75 ms
76,156 KB
testcase_03 AC 81 ms
81,188 KB
testcase_04 AC 103 ms
98,276 KB
testcase_05 AC 79 ms
79,284 KB
testcase_06 AC 98 ms
95,632 KB
testcase_07 AC 92 ms
89,428 KB
testcase_08 AC 90 ms
87,784 KB
testcase_09 AC 103 ms
98,412 KB
testcase_10 AC 118 ms
100,456 KB
testcase_11 AC 80 ms
78,572 KB
testcase_12 AC 77 ms
76,608 KB
testcase_13 AC 117 ms
99,736 KB
testcase_14 AC 86 ms
83,412 KB
testcase_15 AC 85 ms
82,392 KB
testcase_16 AC 84 ms
82,396 KB
testcase_17 AC 82 ms
79,316 KB
testcase_18 AC 123 ms
100,260 KB
testcase_19 AC 103 ms
98,804 KB
testcase_20 AC 77 ms
76,528 KB
testcase_21 AC 93 ms
89,180 KB
testcase_22 AC 74 ms
76,132 KB
testcase_23 AC 78 ms
77,428 KB
testcase_24 AC 83 ms
82,272 KB
testcase_25 AC 115 ms
99,756 KB
testcase_26 AC 90 ms
88,948 KB
testcase_27 AC 83 ms
82,484 KB
testcase_28 AC 81 ms
80,680 KB
testcase_29 AC 102 ms
93,616 KB
testcase_30 AC 87 ms
81,176 KB
testcase_31 AC 100 ms
93,076 KB
testcase_32 AC 127 ms
100,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

ans += b * (b - 1) // 2

print(ans)
0