結果

問題 No.5 数字のブロック
ユーザー pekempeypekempey
提出日時 2016-06-23 09:20:55
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 22 ms
コンパイル使用メモリ 5,120 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-29 07:22:01
合計ジャッジ時間 2,295 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
16,000 KB
testcase_01 AC 27 ms
16,000 KB
testcase_02 AC 25 ms
15,872 KB
testcase_03 AC 51 ms
17,664 KB
testcase_04 AC 47 ms
17,152 KB
testcase_05 AC 56 ms
17,920 KB
testcase_06 AC 46 ms
17,280 KB
testcase_07 AC 45 ms
17,024 KB
testcase_08 AC 50 ms
17,152 KB
testcase_09 AC 31 ms
16,896 KB
testcase_10 AC 57 ms
18,176 KB
testcase_11 AC 43 ms
17,152 KB
testcase_12 AC 54 ms
17,408 KB
testcase_13 AC 55 ms
18,048 KB
testcase_14 AC 26 ms
16,000 KB
testcase_15 AC 27 ms
16,256 KB
testcase_16 AC 55 ms
17,920 KB
testcase_17 AC 64 ms
18,688 KB
testcase_18 AC 59 ms
18,560 KB
testcase_19 AC 64 ms
19,200 KB
testcase_20 AC 25 ms
16,000 KB
testcase_21 AC 25 ms
16,000 KB
testcase_22 AC 25 ms
16,128 KB
testcase_23 AC 25 ms
15,872 KB
testcase_24 AC 26 ms
16,000 KB
testcase_25 AC 27 ms
16,256 KB
testcase_26 AC 26 ms
16,000 KB
testcase_27 AC 25 ms
15,872 KB
testcase_28 AC 26 ms
15,872 KB
testcase_29 AC 46 ms
17,280 KB
testcase_30 AC 32 ms
17,024 KB
testcase_31 AC 25 ms
16,128 KB
testcase_32 AC 25 ms
16,000 KB
testcase_33 AC 26 ms
15,872 KB
権限があれば一括ダウンロードができます

ソースコード

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

(write (let* ((L (read)) (N (read)) (W (sort (map (lambda (x) (read)) (iota N)) <)))
	 (let loop((a W) (sum 0) (res 0))
	   (if (null? a)
	       res
	       (let ((next-sum (+ sum (car a))))
		 (if (<= next-sum L)
		     (loop (cdr a) next-sum (+ res 1))
		     res))))))
(newline)
0