結果

問題 No.2053 12345...
ユーザー dangodango
提出日時 2023-06-14 19:25:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 100,168 KB
最終ジャッジ日時 2023-09-05 06:10:50
合計ジャッジ時間 6,614 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,664 KB
testcase_01 AC 73 ms
70,920 KB
testcase_02 AC 79 ms
75,580 KB
testcase_03 AC 86 ms
80,696 KB
testcase_04 AC 108 ms
97,448 KB
testcase_05 AC 82 ms
78,184 KB
testcase_06 AC 102 ms
94,880 KB
testcase_07 AC 94 ms
88,184 KB
testcase_08 AC 92 ms
86,988 KB
testcase_09 AC 104 ms
97,432 KB
testcase_10 AC 123 ms
100,168 KB
testcase_11 AC 84 ms
77,732 KB
testcase_12 AC 88 ms
76,260 KB
testcase_13 AC 129 ms
99,296 KB
testcase_14 AC 95 ms
83,236 KB
testcase_15 AC 92 ms
81,964 KB
testcase_16 AC 92 ms
81,676 KB
testcase_17 AC 90 ms
78,728 KB
testcase_18 AC 133 ms
99,820 KB
testcase_19 AC 112 ms
98,544 KB
testcase_20 AC 82 ms
75,876 KB
testcase_21 AC 99 ms
88,452 KB
testcase_22 AC 80 ms
75,500 KB
testcase_23 AC 83 ms
76,788 KB
testcase_24 AC 88 ms
81,756 KB
testcase_25 AC 124 ms
99,560 KB
testcase_26 AC 94 ms
88,556 KB
testcase_27 AC 86 ms
81,472 KB
testcase_28 AC 84 ms
79,668 KB
testcase_29 AC 101 ms
92,876 KB
testcase_30 AC 86 ms
80,744 KB
testcase_31 AC 99 ms
92,412 KB
testcase_32 AC 129 ms
100,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def C(n, A):
    count = 0
    i = 0
    while i < n:
        j = i + 1
        while j < n and A[j] - A[j - 1] == 1:
            j += 1
        length = j - i
        if length >= 2:
            count += (length - 1) * length // 2
        i = j
    return count
N = int(input())
A = list(map(int, input().split()))
print(C(N, A))
0