結果
| 問題 |
No.3091 The Little Match Boy
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 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 |
ソースコード
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))