結果
| 問題 |
No.2542 Yokan for Two
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2023-11-24 22:18:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 450 bytes |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 355,660 KB |
| 最終ジャッジ日時 | 2024-09-26 09:28:24 |
| 合計ジャッジ時間 | 4,356 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 TLE * 1 |
| 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