結果

問題 No.3091 The Little Match Boy
コンテスト
ユーザー miya145592
提出日時 2025-04-06 15:38:10
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 296 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 502 ms
コンパイル使用メモリ 95,852 KB
実行使用メモリ 107,752 KB
最終ジャッジ日時 2026-07-08 12:24:38
合計ジャッジ時間 7,314 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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