結果

問題 No.2053 12345...
ユーザー kept1994
提出日時 2022-11-04 01:59:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 82,036 KB
実行使用メモリ 104,108 KB
最終ジャッジ日時 2024-07-18 06:52:00
合計ジャッジ時間 3,702 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
MOD = 998244353
def getArithmeticSequenceSum(a0: int, l: int, n: int):
    return (a0 + l) * n // 2

def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = 1
    ans = 0
    for i in range(N - 1):
        d = A[i + 1] - A[i]
        if d == 1:
            l += 1
        else:
            ans += getArithmeticSequenceSum(1, l - 1, l - 1)
            l = 1
    ans += getArithmeticSequenceSum(1, l - 1, l - 1)
    print(ans)
    return

if __name__ == '__main__':
    main()
0