結果

問題 No.135 とりあえず1次元の問題
ユーザー pekempeypekempey
提出日時 2016-06-23 16:07:26
言語 Scheme
(Gauche-0.9.14)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 23,984 KB
最終ジャッジ日時 2023-09-02 00:27:09
合計ジャッジ時間 3,727 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 426 ms
22,332 KB
testcase_01 AC 17 ms
11,876 KB
testcase_02 AC 17 ms
11,704 KB
testcase_03 WA -
testcase_04 AC 19 ms
11,928 KB
testcase_05 AC 18 ms
11,888 KB
testcase_06 AC 17 ms
11,732 KB
testcase_07 AC 18 ms
11,736 KB
testcase_08 AC 18 ms
11,732 KB
testcase_09 AC 18 ms
11,796 KB
testcase_10 AC 18 ms
11,728 KB
testcase_11 AC 18 ms
11,820 KB
testcase_12 AC 19 ms
11,812 KB
testcase_13 AC 18 ms
11,732 KB
testcase_14 AC 20 ms
12,192 KB
testcase_15 AC 18 ms
11,864 KB
testcase_16 AC 20 ms
12,016 KB
testcase_17 AC 20 ms
12,016 KB
testcase_18 AC 18 ms
11,896 KB
testcase_19 AC 20 ms
12,080 KB
testcase_20 AC 19 ms
11,980 KB
testcase_21 AC 296 ms
23,984 KB
testcase_22 AC 427 ms
23,980 KB
evil01.txt AC 381 ms
25,996 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) -1 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