結果

問題 No.143 豆
ユーザー pekempeypekempey
提出日時 2016-06-23 17:28:08
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 546 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 11,920 KB
最終ジャッジ日時 2023-09-30 16:46:39
合計ジャッジ時間 1,385 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
11,792 KB
testcase_01 AC 19 ms
11,668 KB
testcase_02 AC 18 ms
11,920 KB
testcase_03 AC 18 ms
11,680 KB
testcase_04 AC 19 ms
11,696 KB
testcase_05 AC 19 ms
11,732 KB
testcase_06 AC 18 ms
11,780 KB
testcase_07 AC 19 ms
11,748 KB
testcase_08 AC 18 ms
11,916 KB
testcase_09 AC 19 ms
11,760 KB
testcase_10 AC 20 ms
11,732 KB
testcase_11 AC 19 ms
11,704 KB
testcase_12 AC 19 ms
11,816 KB
testcase_13 AC 19 ms
11,848 KB
testcase_14 AC 18 ms
11,736 KB
testcase_15 AC 19 ms
11,772 KB
testcase_16 AC 18 ms
11,680 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))))))

(define (sum a)
  (if (null? a) 0 (+ (car a) (sum (cdr a)))))

(define (solve K N F A)
  (max -1 (- (* K N) (sum A))))

(display (let ((K (read)) (N (read)) (F (read)))
	   (let ((A (map (lambda (x) (read)) (iota F))))
	     (solve K N F A))))
(newline)
0