結果

問題 No.615 集合に分けよう
ユーザー nebukuro09nebukuro09
提出日時 2017-12-15 13:34:24
言語 Scheme
(Gauche-0.9.15)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 32,384 KB
最終ジャッジ日時 2024-12-14 15:56:39
合計ジャッジ時間 7,172 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

(define nm (read (open-input-string (format "(~a)" (read-line)))))
(define n (car nm))
(define m (cadr nm))
(define a (sort (read (open-input-string (format "(~a)" (read-line)))) <)) 

(define (diff n lst) (if (= n 1) '() (cons (- (cadr lst) (car lst)) (diff (- n 1) (cdr lst)))))
(define b (diff n a))

(print (- (fold + 0 b) (fold + 0 (take (sort b >) (- m 1)))))
0