結果

問題 No.2053 12345...
ユーザー kept1994kept1994
提出日時 2022-11-04 01:59:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 522 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 100,404 KB
最終ジャッジ日時 2023-09-25 08:21:40
合計ジャッジ時間 6,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,084 KB
testcase_01 AC 70 ms
71,300 KB
testcase_02 AC 75 ms
75,900 KB
testcase_03 AC 83 ms
80,920 KB
testcase_04 AC 102 ms
97,972 KB
testcase_05 AC 80 ms
78,724 KB
testcase_06 AC 100 ms
95,268 KB
testcase_07 AC 93 ms
88,920 KB
testcase_08 AC 89 ms
87,168 KB
testcase_09 AC 101 ms
98,080 KB
testcase_10 AC 115 ms
100,404 KB
testcase_11 AC 76 ms
78,036 KB
testcase_12 AC 76 ms
76,564 KB
testcase_13 AC 120 ms
99,596 KB
testcase_14 AC 86 ms
83,292 KB
testcase_15 AC 82 ms
82,380 KB
testcase_16 AC 82 ms
82,320 KB
testcase_17 AC 79 ms
79,048 KB
testcase_18 AC 122 ms
100,128 KB
testcase_19 AC 103 ms
98,592 KB
testcase_20 AC 76 ms
76,340 KB
testcase_21 AC 91 ms
89,072 KB
testcase_22 AC 72 ms
75,972 KB
testcase_23 AC 76 ms
77,096 KB
testcase_24 AC 83 ms
81,976 KB
testcase_25 AC 116 ms
99,848 KB
testcase_26 AC 89 ms
88,748 KB
testcase_27 AC 83 ms
82,092 KB
testcase_28 AC 81 ms
80,208 KB
testcase_29 AC 96 ms
93,308 KB
testcase_30 AC 82 ms
81,132 KB
testcase_31 AC 96 ms
93,252 KB
testcase_32 AC 123 ms
100,320 KB
権限があれば一括ダウンロードができます

ソースコード

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