結果
| 問題 |
No.185 和風
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-23 11:56:03 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 1,000 ms |
| コード長 | 773 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 16,640 KB |
| 最終ジャッジ日時 | 2024-10-11 19:54:42 |
| 合計ジャッジ時間 | 700 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
ソースコード
(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)