結果

問題 No.185 和風
ユーザー pekempeypekempey
提出日時 2016-06-23 11:56:03
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 24 ms / 1,000 ms
コード長 773 bytes
コンパイル時間 32 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2024-04-20 01:07:07
合計ジャッジ時間 713 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
16,000 KB
testcase_01 AC 23 ms
16,512 KB
testcase_02 AC 24 ms
16,640 KB
testcase_03 AC 22 ms
16,640 KB
testcase_04 AC 22 ms
16,512 KB
testcase_05 AC 20 ms
16,000 KB
testcase_06 AC 22 ms
16,512 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 (min-element a)
  (if (null? (cdr a)) (car a) (min (car a) (min-element (cdr a)))))

(define (max-element a)
  (if (null? (cdr a)) (car a) (max (car a) (max-element (cdr a)))))

(define (unique? a)
  (= (min-element a) (max-element a)))

(define (solve a)
  (let ((b (map (lambda (x) (- (cdr x) (car x))) a)))
    (if (unique? b)
	(if (positive? (car b)) (car b) -1)
	-1)))
  
(display (solve (let ((N (read))) (map (lambda (x) (cons (read) (read))) (iota N)))))
(newline)
0