結果

問題 No.615 集合に分けよう
ユーザー momen999momen999
提出日時 2019-03-07 10:34:06
言語 Haskell
(9.8.2)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 162,408 KB
実行使用メモリ 40,196 KB
最終ジャッジ日時 2023-09-05 19:21:40
合計ジャッジ時間 5,202 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,256 KB
testcase_01 AC 3 ms
7,352 KB
testcase_02 AC 2 ms
7,024 KB
testcase_03 AC 3 ms
7,340 KB
testcase_04 AC 2 ms
7,220 KB
testcase_05 AC 3 ms
7,264 KB
testcase_06 AC 2 ms
7,452 KB
testcase_07 AC 3 ms
7,908 KB
testcase_08 AC 3 ms
7,864 KB
testcase_09 AC 3 ms
7,916 KB
testcase_10 AC 3 ms
7,752 KB
testcase_11 AC 3 ms
7,720 KB
testcase_12 AC 3 ms
7,120 KB
testcase_13 AC 6 ms
11,500 KB
testcase_14 AC 13 ms
11,644 KB
testcase_15 AC 62 ms
17,352 KB
testcase_16 AC 62 ms
37,888 KB
testcase_17 AC 322 ms
40,196 KB
testcase_18 AC 322 ms
40,140 KB
testcase_19 AC 332 ms
40,108 KB
testcase_20 AC 322 ms
40,188 KB
testcase_21 AC 312 ms
40,188 KB
testcase_22 AC 333 ms
40,180 KB
testcase_23 AC 162 ms
21,812 KB
testcase_24 AC 322 ms
39,072 KB
testcase_25 AC 2 ms
6,948 KB
testcase_26 AC 3 ms
7,060 KB
testcase_27 AC 82 ms
20,696 KB
testcase_28 AC 83 ms
20,604 KB
testcase_29 AC 202 ms
37,964 KB
testcase_30 AC 213 ms
38,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List

rInteger :: String -> Integer
rInteger = read

solve :: Int -> Int -> [Integer] -> Integer
solve 1 _ as = 0
solve n k as = foldr (+) 0 ts where
    ts = take (n - k) $ sort xs
    xs = zipWith (-) (reverse (tail as)) (reverse (init as))
main = do
    [n, k] <- map read . words <$> getLine
    as <- sort . map rInteger . words <$> getLine
    print $ solve n k as
0