結果

問題 No.156 キャンディー・ボックス
ユーザー pekempeypekempey
提出日時 2016-06-23 16:43:33
言語 Scheme
(Gauche-0.9.14)
結果
TLE  
実行時間 -
コード長 683 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 27,808 KB
最終ジャッジ日時 2024-04-20 01:24:42
合計ジャッジ時間 5,775 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 211 ms
27,676 KB
testcase_01 AC 21 ms
15,872 KB
testcase_02 AC 24 ms
15,872 KB
testcase_03 AC 25 ms
16,000 KB
testcase_04 AC 25 ms
15,872 KB
testcase_05 AC 1,441 ms
20,736 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

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 (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)
0