結果

問題 No.2053 12345...
ユーザー SyuKing_OrderSyuKing_Order
提出日時 2022-08-21 13:02:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 112,152 KB
最終ジャッジ日時 2024-04-18 12:46:58
合計ジャッジ時間 3,406 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
51,712 KB
testcase_01 AC 41 ms
51,456 KB
testcase_02 AC 43 ms
59,776 KB
testcase_03 AC 52 ms
72,960 KB
testcase_04 AC 79 ms
103,424 KB
testcase_05 AC 48 ms
69,248 KB
testcase_06 AC 77 ms
98,944 KB
testcase_07 AC 64 ms
87,296 KB
testcase_08 AC 61 ms
84,480 KB
testcase_09 AC 83 ms
103,680 KB
testcase_10 AC 95 ms
104,192 KB
testcase_11 AC 49 ms
68,352 KB
testcase_12 AC 44 ms
64,512 KB
testcase_13 AC 96 ms
103,936 KB
testcase_14 AC 53 ms
77,184 KB
testcase_15 AC 53 ms
74,880 KB
testcase_16 AC 53 ms
75,008 KB
testcase_17 AC 49 ms
69,248 KB
testcase_18 AC 107 ms
111,800 KB
testcase_19 AC 81 ms
104,832 KB
testcase_20 AC 43 ms
63,232 KB
testcase_21 AC 66 ms
86,784 KB
testcase_22 AC 40 ms
59,008 KB
testcase_23 AC 45 ms
65,792 KB
testcase_24 AC 53 ms
74,368 KB
testcase_25 AC 90 ms
104,320 KB
testcase_26 AC 63 ms
86,912 KB
testcase_27 AC 52 ms
74,240 KB
testcase_28 AC 49 ms
71,168 KB
testcase_29 AC 70 ms
95,360 KB
testcase_30 AC 51 ms
72,448 KB
testcase_31 AC 74 ms
94,592 KB
testcase_32 AC 109 ms
112,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])
count = 0
ans = 0
for i in range(n-1):
    if b[i] == 1:
        count += 1
    else:
        ans += (1+count)*count//2
        count = 0
ans += (1+count)*count//2
print(ans)
    
0