結果

問題 No.406 鴨等間隔の法則
ユーザー 情報学生情報学生
提出日時 2019-08-23 18:20:58
言語 Haskell
(9.8.2)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 1,061 ms
コンパイル使用メモリ 161,500 KB
実行使用メモリ 24,972 KB
最終ジャッジ日時 2023-09-21 19:32:32
合計ジャッジ時間 3,966 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
13,948 KB
testcase_01 AC 2 ms
7,344 KB
testcase_02 AC 3 ms
7,424 KB
testcase_03 AC 3 ms
7,416 KB
testcase_04 AC 32 ms
16,976 KB
testcase_05 AC 32 ms
14,672 KB
testcase_06 AC 22 ms
14,040 KB
testcase_07 AC 22 ms
13,968 KB
testcase_08 AC 32 ms
16,892 KB
testcase_09 AC 42 ms
21,012 KB
testcase_10 AC 22 ms
14,496 KB
testcase_11 AC 32 ms
17,468 KB
testcase_12 AC 22 ms
15,060 KB
testcase_13 AC 22 ms
15,268 KB
testcase_14 AC 142 ms
23,864 KB
testcase_15 AC 4 ms
8,652 KB
testcase_16 AC 12 ms
11,872 KB
testcase_17 AC 6 ms
10,996 KB
testcase_18 AC 4 ms
9,720 KB
testcase_19 AC 12 ms
12,368 KB
testcase_20 AC 22 ms
12,684 KB
testcase_21 AC 22 ms
12,604 KB
testcase_22 AC 32 ms
13,728 KB
testcase_23 AC 22 ms
14,984 KB
testcase_24 AC 122 ms
20,816 KB
testcase_25 AC 43 ms
21,304 KB
testcase_26 AC 173 ms
24,908 KB
testcase_27 AC 22 ms
17,640 KB
testcase_28 AC 22 ms
16,520 KB
testcase_29 AC 173 ms
24,920 KB
testcase_30 AC 172 ms
24,972 KB
testcase_31 AC 42 ms
20,968 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.Applicative ((<$>))
import Data.Char (isSpace)
import Data.List (unfoldr, sort)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

getL :: (ByteString -> [Int]) -> IO [Int]
getL f = f <$> B.getLine

readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int])
readIL f = unfoldr g
    where
        g s = do
            (n, s') <- f s
            return (n, B.dropWhile isSpace s')

main :: IO ()
main = do
    B.getLine
    putStrLn =<< solve <$> getL (readIL B.readInt)

solve :: [Int] -> String
solve xs = if any (== 0) xss then "NO" else if all (== (head xss)) xss then "YES" else "NO"
    where
        xss = f $ sort xs
        f :: [Int] -> [Int]
        f [x]      = []
        f (x:y:ys) = (y - x) : f (y:ys)
0