結果

問題 No.156 キャンディー・ボックス
ユーザー pekempeypekempey
提出日時 2016-06-23 16:45:54
言語 Scheme
(Gauche-0.9.14)
結果
TLE  
実行時間 -
コード長 700 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 41,728 KB
最終ジャッジ日時 2024-04-19 23:48:02
合計ジャッジ時間 6,164 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
41,728 KB
testcase_01 AC 29 ms
15,872 KB
testcase_02 AC 22 ms
15,872 KB
testcase_03 AC 21 ms
15,872 KB
testcase_04 AC 26 ms
15,872 KB
testcase_05 AC 1,168 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 loop((M M) (C C))
    (let ((C (filter positive? C)))
      (if (zero? M)
	  C
	  (loop (- 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