結果

問題 No.29 パワーアップ
ユーザー MiyamonYMiyamonY
提出日時 2019-09-03 14:06:49
言語 Scheme
(Gauche-0.9.11-p1)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 33 ms
使用メモリ 14,276 KB
最終ジャッジ日時 2023-01-13 06:48:02
合計ジャッジ時間 1,991 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 23 ms
12,384 KB
testcase_01 AC 23 ms
12,204 KB
testcase_02 AC 23 ms
12,428 KB
testcase_03 AC 23 ms
12,232 KB
testcase_04 AC 23 ms
12,400 KB
testcase_05 AC 23 ms
12,244 KB
testcase_06 AC 23 ms
12,272 KB
testcase_07 AC 23 ms
12,224 KB
testcase_08 AC 22 ms
12,404 KB
testcase_09 AC 22 ms
12,236 KB
testcase_10 AC 23 ms
12,400 KB
testcase_11 AC 22 ms
12,496 KB
testcase_12 AC 22 ms
12,212 KB
testcase_13 AC 24 ms
12,416 KB
testcase_14 AC 24 ms
14,276 KB
testcase_15 AC 23 ms
12,240 KB
testcase_16 AC 23 ms
12,276 KB
testcase_17 AC 23 ms
12,272 KB
testcase_18 AC 23 ms
12,320 KB
testcase_19 AC 23 ms
12,392 KB
testcase_20 AC 23 ms
12,224 KB
testcase_21 AC 23 ms
12,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define (read-number)
  (string->number (read-line)))

(define vec (make-vector 10 0))

(define extra 0)

(let ((_ (read-number)))
  (let loop ((row (read-line)))
    (cond ((eof-object? row) '())
	  (else
	   (let loop-inner ((column (map string->number (string-split row #\space))))
	     (if (null? column)
		 '()
		 (let ((n (car column)))
		   (vector-set! vec (- n 1) (+ 1 (vector-ref vec (- n 1))))
		   (loop-inner (cdr column)))))
	   (loop (read-line)))))

  (let1 total (fold + 0
		    (map (lambda (n)
			   (set! extra (+ extra (mod (vector-ref vec n) 2)))
			   (div (vector-ref vec n) 2)) (iota 10)))
	(print (+ total (div extra 4)))))
0