結果

問題 No.2053 12345...
ユーザー DrDrpilotDrDrpilot
提出日時 2022-08-23 17:52:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 321 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 100,116 KB
最終ジャッジ日時 2024-04-19 09:04:51
合計ジャッジ時間 3,917 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,632 KB
testcase_01 AC 40 ms
53,504 KB
testcase_02 WA -
testcase_03 AC 58 ms
74,240 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 45 ms
61,816 KB
testcase_23 AC 49 ms
67,596 KB
testcase_24 AC 57 ms
76,732 KB
testcase_25 AC 97 ms
99,268 KB
testcase_26 AC 65 ms
86,764 KB
testcase_27 AC 56 ms
76,168 KB
testcase_28 AC 55 ms
72,816 KB
testcase_29 AC 79 ms
94,640 KB
testcase_30 AC 56 ms
74,796 KB
testcase_31 AC 78 ms
94,832 KB
testcase_32 AC 104 ms
100,116 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()
ans+=len(q)*(len(q)-1)//2
print(ans)
0