結果

問題 No.2053 12345...
ユーザー DrDrpilotDrDrpilot
提出日時 2022-08-23 17:52:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,480 KB
実行使用メモリ 99,824 KB
最終ジャッジ日時 2024-04-19 09:05:37
合計ジャッジ時間 3,858 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
54,176 KB
testcase_01 AC 40 ms
55,372 KB
testcase_02 AC 46 ms
63,416 KB
testcase_03 AC 55 ms
75,580 KB
testcase_04 AC 90 ms
98,384 KB
testcase_05 AC 56 ms
72,584 KB
testcase_06 AC 87 ms
95,772 KB
testcase_07 AC 74 ms
89,756 KB
testcase_08 AC 72 ms
87,680 KB
testcase_09 AC 88 ms
98,260 KB
testcase_10 AC 102 ms
99,824 KB
testcase_11 AC 55 ms
70,776 KB
testcase_12 AC 56 ms
70,516 KB
testcase_13 AC 107 ms
98,936 KB
testcase_14 AC 69 ms
81,832 KB
testcase_15 AC 64 ms
79,676 KB
testcase_16 AC 64 ms
78,304 KB
testcase_17 AC 60 ms
74,544 KB
testcase_18 AC 112 ms
99,576 KB
testcase_19 AC 90 ms
98,416 KB
testcase_20 AC 52 ms
67,100 KB
testcase_21 AC 80 ms
88,940 KB
testcase_22 AC 45 ms
62,284 KB
testcase_23 AC 50 ms
68,152 KB
testcase_24 AC 57 ms
75,948 KB
testcase_25 AC 96 ms
99,100 KB
testcase_26 AC 66 ms
86,708 KB
testcase_27 AC 57 ms
76,884 KB
testcase_28 AC 55 ms
73,984 KB
testcase_29 AC 77 ms
94,628 KB
testcase_30 AC 56 ms
74,156 KB
testcase_31 AC 77 ms
94,436 KB
testcase_32 AC 103 ms
99,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
n=int(input())
a=list(map(int,input().split()))
q=deque()
ans=0
for i in a:
    if len(q)==0:
        q.append(i)
        continue
    if q[-1]+1==i:
        q.append(i)
    else:
        ans+=len(q)*(len(q)-1)//2
        while q:
            q.popleft()
        q.append(i)
ans+=len(q)*(len(q)-1)//2
print(ans)
0