結果

問題 No.135 とりあえず1次元の問題
ユーザー pekempeypekempey
提出日時 2016-06-23 16:08:31
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 434 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 24,020 KB
最終ジャッジ日時 2023-09-02 00:27:17
合計ジャッジ時間 3,776 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 430 ms
20,236 KB
testcase_01 AC 19 ms
11,708 KB
testcase_02 AC 19 ms
11,884 KB
testcase_03 AC 18 ms
11,704 KB
testcase_04 AC 19 ms
11,796 KB
testcase_05 AC 19 ms
11,748 KB
testcase_06 AC 19 ms
11,732 KB
testcase_07 AC 19 ms
11,972 KB
testcase_08 AC 19 ms
11,752 KB
testcase_09 AC 18 ms
11,748 KB
testcase_10 AC 19 ms
11,804 KB
testcase_11 AC 18 ms
11,784 KB
testcase_12 AC 19 ms
11,912 KB
testcase_13 AC 18 ms
11,932 KB
testcase_14 AC 21 ms
12,160 KB
testcase_15 AC 20 ms
11,824 KB
testcase_16 AC 21 ms
12,072 KB
testcase_17 AC 21 ms
12,080 KB
testcase_18 AC 19 ms
11,808 KB
testcase_19 AC 20 ms
12,212 KB
testcase_20 AC 19 ms
12,088 KB
testcase_21 AC 305 ms
24,020 KB
testcase_22 AC 434 ms
20,348 KB
evil01.txt AC 385 ms
24,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (iota n . args)
  (let ((start (if (pair? args) (car args) 0))
        (step  (if (and (pair? args) (pair? (cdr args))) (cadr args) 1)))
    (let loop ((m n) (last (+ start (* step (- n 1)))) (a '()))
      (if (zero? m)
          a
	  (loop (- m 1) (- last step) (cons last a))))))

(define (solve a)
  (let loop((b (sort a <)) (prev -1001001001) (res 1001001001))
    (if (null? b)
	(if (= res 1001001001) 0 res)
	(let ((curr (car b)))
	  (if (= curr prev)
	      (loop (cdr b) curr res)
	      (loop (cdr b) curr (min res (- curr prev))))))))

(display (solve (let ((N (read))) (map (lambda (x) (read)) (iota N)))))
(newline)
0