結果

問題 No.5 数字のブロック
ユーザー pekempeypekempey
提出日時 2016-06-23 09:20:55
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 5,280 KB
実行使用メモリ 14,000 KB
最終ジャッジ日時 2023-08-11 15:12:41
合計ジャッジ時間 2,664 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
11,876 KB
testcase_01 AC 18 ms
11,672 KB
testcase_02 AC 18 ms
11,768 KB
testcase_03 AC 42 ms
13,860 KB
testcase_04 AC 36 ms
13,864 KB
testcase_05 AC 44 ms
13,788 KB
testcase_06 AC 39 ms
13,784 KB
testcase_07 AC 29 ms
13,460 KB
testcase_08 AC 40 ms
13,780 KB
testcase_09 AC 23 ms
12,460 KB
testcase_10 AC 47 ms
13,756 KB
testcase_11 AC 28 ms
13,388 KB
testcase_12 AC 41 ms
13,764 KB
testcase_13 AC 44 ms
13,784 KB
testcase_14 AC 18 ms
11,844 KB
testcase_15 AC 19 ms
11,784 KB
testcase_16 AC 46 ms
13,964 KB
testcase_17 AC 50 ms
13,764 KB
testcase_18 AC 48 ms
13,812 KB
testcase_19 AC 51 ms
14,000 KB
testcase_20 AC 17 ms
11,676 KB
testcase_21 AC 18 ms
11,772 KB
testcase_22 AC 18 ms
11,676 KB
testcase_23 AC 18 ms
11,708 KB
testcase_24 AC 19 ms
11,876 KB
testcase_25 AC 20 ms
11,872 KB
testcase_26 AC 19 ms
11,916 KB
testcase_27 AC 19 ms
13,680 KB
testcase_28 AC 18 ms
11,760 KB
testcase_29 AC 32 ms
13,876 KB
testcase_30 AC 25 ms
12,664 KB
testcase_31 AC 18 ms
11,688 KB
testcase_32 AC 18 ms
11,872 KB
testcase_33 AC 18 ms
11,768 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