結果

問題 No.3091 The Little Match Boy
ユーザー miya145592
提出日時 2025-04-06 15:38:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 296 bytes
コンパイル時間 718 ms
コンパイル使用メモリ 82,712 KB
実行使用メモリ 95,744 KB
最終ジャッジ日時 2025-04-06 15:38:18
合計ジャッジ時間 6,436 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N, M = map(int, input().split())
S = list(map(int, input().split()))
ans = set()
dp = [i for i in range(N)]
for s in S:
    s-=1
    a, b = dp[s], dp[s+1]
    if a>b:
        a, b = b, a
    ans.add((a, b))
    dp[s], dp[s+1] = dp[s+1], dp[s]
print(len(ans))
0