結果

問題 No.837 Noelちゃんと星々2
ユーザー pekempeypekempey
提出日時 2019-06-15 02:34:22
言語 Haskell
(9.8.2)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 500 bytes
コンパイル時間 10,842 ms
コンパイル使用メモリ 164,892 KB
実行使用メモリ 66,484 KB
最終ジャッジ日時 2023-09-02 07:24:23
合計ジャッジ時間 17,745 ms
ジャッジサーバーID
(参考情報)
judge12 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 624 ms
66,484 KB
testcase_01 AC 592 ms
65,924 KB
testcase_02 AC 603 ms
65,360 KB
testcase_03 AC 592 ms
66,140 KB
testcase_04 AC 601 ms
65,424 KB
testcase_05 AC 602 ms
65,728 KB
testcase_06 AC 603 ms
65,696 KB
testcase_07 AC 592 ms
65,612 KB
testcase_08 AC 603 ms
65,332 KB
testcase_09 AC 3 ms
7,852 KB
testcase_10 AC 3 ms
7,520 KB
testcase_11 AC 3 ms
7,456 KB
testcase_12 AC 3 ms
7,336 KB
testcase_13 AC 3 ms
7,264 KB
testcase_14 AC 3 ms
7,760 KB
testcase_15 AC 3 ms
7,852 KB
testcase_16 AC 3 ms
7,152 KB
testcase_17 AC 3 ms
7,568 KB
testcase_18 AC 3 ms
7,224 KB
testcase_19 AC 3 ms
7,308 KB
testcase_20 AC 3 ms
7,656 KB
testcase_21 AC 3 ms
7,880 KB
testcase_22 AC 3 ms
7,744 KB
testcase_23 AC 3 ms
7,512 KB
testcase_24 AC 3 ms
7,112 KB
testcase_25 AC 2 ms
7,148 KB
testcase_26 AC 2 ms
7,024 KB
testcase_27 AC 3 ms
7,164 KB
testcase_28 AC 2 ms
7,068 KB
testcase_29 AC 3 ms
7,180 KB
testcase_30 AC 2 ms
7,100 KB
testcase_31 AC 2 ms
7,000 KB
testcase_32 AC 3 ms
7,156 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 Control.Monad
import Data.List
import Data.Array

main :: IO ()
main = do
  _ <- getLine
  a <- map read . words <$> getLine :: IO [Int]
  print $ f a

f :: [Int] -> Int
f a = if minimum a == maximum a
        then 1
        else minimum [ g s 0 i + g s i n  | i <- [1..n-1] ]
  where
    n = length a
    s = listArray (0, n) $ scanl (+) 0 (sort a)

g :: Array Int Int -> Int -> Int -> Int
g s l r = let m1 = (l + r) `div` 2; m2 = (l + r + 1) `div` 2
          in (s!r - s!m2) - (s!m1 - s!l)
0