結果

問題 No.182 新規性の虜
ユーザー pekempey
提出日時 2016-06-23 12:18:56
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 450 ms / 5,000 ms
コード長 720 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 5,248 KB
実行使用メモリ 27,392 KB
最終ジャッジ日時 2024-12-27 05:10:10
合計ジャッジ時間 7,095 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

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 (count-same a)
  (let ((head (car a)))
    (let loop((b a) (res 0))
      (if (null? b)
	  res
	  (if (= head (car b))
	      (loop (cdr b) (+ res 1))
	      res)))))

(define (solve a)
  (let loop((b (sort a <)) (res 0))
    (if (null? b)
	res
	(let ((cnt (count-same b)))
      	  (loop (drop b cnt) (if (= cnt 1) (+ res 1) res))))))
	
(display (solve (let ((N (read))) (map (lambda (x) (read)) (iota N)))))
(newline)
0