- 积分
- 18528
- 明经币
- 个
- 注册时间
- 2013-10-29
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
(defun tt(lst)
(defun f1 (plst j num)
(setq ij -1)
(setq plst (mapcar '(lambda (x) (if (= (setq ij (+ ij 1)) j) num x)) plst))
)
(setq n (length lst) i 0 ans 0 vlst '(nil))
(repeat n (setq vlst (cons nil vlst)))
(while (< i n)
(setq l 0 r ans)
(while (< l r)
(setq mid (/ (+ l r) 2))
(if (<= (nth mid vlst) (nth i lst))
(setq l (+ mid 1))
(setq r mid)
)
)
(setq vlst (f1 vlst l (nth i lst)))
(if (= l ans) (setq ans (+ ans 1)))
(setq i (+ i 1))
)
(setq vlst (reverse (vl-remove nil vlst)) alst (reverse lst) blst (list (+ 1 (car vlst))))
(while vlst
(if (and (>= (car alst) (car vlst)) (<= (car alst) (car blst)))
(progn
(setq blst (cons (car alst) blst))
(setq vlst (cdr vlst))
(setq alst (cdr alst))
)
(setq alst (cdr alst))
)
)
(reverse (cdr (reverse blst)))
)
_$ (tt '(0 0 2 4 1 5 1 3 1 2 0 8 9 10 4 6))
(0 0 1 1 1 2 8 9 10)
_$ (tt '(0 0 2 4 1 5 1 3 1 2 0 8 9 10 4 6 7))
(0 0 1 1 1 2 4 6 7)
_$ (tt '(5 1 3 2 0 8 9 10 4 6 7))
(1 2 4 6 7)
_$ (tt '(3 5 4 6 10 0 1 9 8 2 7))
(0 1 2 7)
_$ (tt '(0 1 9 10 2 3 4 5 6 8 7))
(0 1 2 3 4 5 6 7)
_$ (tt '(6 1 0 3 11 10 4 5 8 9 2 7))
(0 3 4 5 8 9)
_$
|
|