結果

問題 No.185 和風
ユーザー pekempeypekempey
提出日時 2016-06-23 09:53:46
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 808 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 16,768 KB
最終ジャッジ日時 2024-04-20 01:06:54
合計ジャッジ時間 1,047 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
16,000 KB
testcase_01 AC 29 ms
16,512 KB
testcase_02 AC 27 ms
16,512 KB
testcase_03 AC 28 ms
16,640 KB
testcase_04 AC 28 ms
16,768 KB
testcase_05 AC 26 ms
16,256 KB
testcase_06 AC 27 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? a)
      1001001001
      (min (car a) (min-element (cdr a)))))

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

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

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