結果

問題 No.1373 Directed Operations
ユーザー linuxmetellinuxmetel
提出日時 2021-02-05 22:08:08
言語 Common Lisp
(sbcl 2.3.8)
結果
AC  
実行時間 291 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 32,308 KB
実行使用メモリ 31,996 KB
最終ジャッジ日時 2023-09-15 08:18:23
合計ジャッジ時間 5,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
23,068 KB
testcase_01 AC 8 ms
22,956 KB
testcase_02 AC 203 ms
30,748 KB
testcase_03 AC 49 ms
30,056 KB
testcase_04 AC 91 ms
31,440 KB
testcase_05 AC 9 ms
27,088 KB
testcase_06 AC 288 ms
30,768 KB
testcase_07 AC 14 ms
23,284 KB
testcase_08 AC 36 ms
26,008 KB
testcase_09 AC 140 ms
30,736 KB
testcase_10 AC 114 ms
31,592 KB
testcase_11 AC 34 ms
26,008 KB
testcase_12 AC 110 ms
28,588 KB
testcase_13 AC 20 ms
23,664 KB
testcase_14 AC 291 ms
31,996 KB
testcase_15 AC 251 ms
30,652 KB
testcase_16 AC 289 ms
30,792 KB
testcase_17 AC 165 ms
28,612 KB
testcase_18 AC 98 ms
28,380 KB
testcase_19 AC 116 ms
26,176 KB
testcase_20 AC 158 ms
31,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 15 SEP 2023 08:18:18 AM):
; processing (DEFVAR N ...)
; processing (DEFPARAMETER A ...)
; processing (DEFVAR F ...)
; processing (DEFPARAMETER ANS ...)
; processing (LOOP FOR ...)
; processing (IF F ...)

; wrote /home/judge/data/code/Main.fasl
; compilation finished in 0:00:00.008

ソースコード

diff #

(defvar n (read))

(defparameter a (sort (apply #'vector (cons -100000000 1) (loop for i from 1 to (1- n)
                                                                collect (cons (read) i)))
                             #'(lambda (x y) (< (car x) (car y)))))

(defvar f nil)

(defparameter ans (make-array n))

(loop for i from 1 to (1- n)
      until f
      do (if (<= (car (aref a i)) i)
             (setf (aref ans (cdr (aref a i))) (1+ (- i (car (aref a i)))))
             (setq f t)))

(if f
    (progn (princ "NO")
           (fresh-line))
    (progn (princ "YES")
           (fresh-line)
           (loop for i from 1 to (1- n)
                 do (princ (aref ans i))
                    (fresh-line))))
;(princ a)
0