結果
問題 | No.406 鴨等間隔の法則 |
ユーザー | 情報学生 |
提出日時 | 2019-08-23 18:20:58 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 8,326 ms |
コンパイル使用メモリ | 180,780 KB |
実行使用メモリ | 21,888 KB |
最終ジャッジ日時 | 2024-07-07 13:07:50 |
合計ジャッジ時間 | 8,514 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
10,624 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 23 ms
13,568 KB |
testcase_05 | AC | 19 ms
11,008 KB |
testcase_06 | AC | 10 ms
10,496 KB |
testcase_07 | AC | 10 ms
10,496 KB |
testcase_08 | AC | 22 ms
13,440 KB |
testcase_09 | AC | 24 ms
13,952 KB |
testcase_10 | AC | 16 ms
11,904 KB |
testcase_11 | AC | 22 ms
13,696 KB |
testcase_12 | AC | 19 ms
12,672 KB |
testcase_13 | AC | 11 ms
10,496 KB |
testcase_14 | AC | 126 ms
20,736 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 8 ms
8,192 KB |
testcase_17 | AC | 5 ms
7,168 KB |
testcase_18 | AC | 3 ms
5,760 KB |
testcase_19 | AC | 9 ms
8,704 KB |
testcase_20 | AC | 12 ms
8,832 KB |
testcase_21 | AC | 12 ms
8,960 KB |
testcase_22 | AC | 24 ms
9,856 KB |
testcase_23 | AC | 16 ms
12,288 KB |
testcase_24 | AC | 98 ms
17,664 KB |
testcase_25 | AC | 25 ms
13,952 KB |
testcase_26 | AC | 153 ms
21,760 KB |
testcase_27 | AC | 19 ms
14,720 KB |
testcase_28 | AC | 17 ms
14,464 KB |
testcase_29 | AC | 154 ms
21,888 KB |
testcase_30 | AC | 157 ms
21,888 KB |
testcase_31 | AC | 27 ms
14,336 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:23:57: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 23 | solve xs = if any (== 0) xss then "NO" else if all (== (head xss)) xss then "YES" else "NO" | ^^^^ [2 of 2] Linking a.out
ソースコード
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)