結果
| 問題 | No.2542 Yokan for Two |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-11-24 22:18:01 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 450 bytes |
| 記録 | |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 390,880 KB |
| 最終ジャッジ日時 | 2026-04-13 12:35:00 |
| 合計ジャッジ時間 | 6,595 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | TLE * 1 -- * 39 |
ソースコード
import sys
input = sys.stdin.readline
L,N=map(int,input().split())
X=[0]+list(map(int,input().split()))+[L]
DP={(0,0,0)}
for i in range(1,N+2):
NDP=set()
for ind,d,com in DP:
if com==0:
NDP.add((i,d+X[i]-X[ind],1))
else:
NDP.add((i,d-(X[i]-X[ind]),0))
if i!=N+1:
DP=NDP|DP
else:
DP=NDP
ANS=1<<60
for ind,d,com in DP:
if com==0:
ANS=min(ANS,abs(d))
print(ANS)
titia