結果
| 問題 | No.156 キャンディー・ボックス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-23 16:43:33 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 683 bytes |
| 記録 | |
| コンパイル時間 | 65 ms |
| コンパイル使用メモリ | 6,400 KB |
| 実行使用メモリ | 27,776 KB |
| 最終ジャッジ日時 | 2026-04-28 05:11:02 |
| 合計ジャッジ時間 | 24,445 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 TLE * 4 -- * 3 |
ソースコード
(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 (take-candy a)
(let ((a (sort a <)))
(cons (- (car a) 1) (cdr a))))
(define (take-candy-rec M C)
(let ((C (filter positive? C)))
(if (zero? M)
C
(take-candy-rec (- M 1) (take-candy C)))))
(define (solve N M C)
(- N (length (take-candy-rec M C))))
(display (let* ((N (read)) (M (read)) (C (map (lambda (x) (read)) (iota N)))) (solve N M C)))
(newline)