結果

問題 No.182 新規性の虜
コンテスト
ユーザー pekempey
提出日時 2016-06-23 12:18:56
言語 Scheme
(Gauche-0.9.15)
コンパイル:
true
実行:
gosh _filename_
結果
AC  
実行時間 258 ms / 5,000 ms
コード長 720 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 6,400 KB
実行使用メモリ 27,648 KB
最終ジャッジ日時 2026-06-01 22:08:37
合計ジャッジ時間 4,842 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

(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