結果
問題 |
No.156 キャンディー・ボックス
|
ユーザー |
|
提出日時 | 2016-06-23 16:43:33 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 71 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 27,552 KB |
最終ジャッジ日時 | 2024-10-11 20:14:45 |
合計ジャッジ時間 | 5,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 1 -- * 27 |
ソースコード
(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)