結果

問題 No.406 鴨等間隔の法則
ユーザー Naoki_M_Naoki_M_
提出日時 2016-08-13 13:15:53
言語 Haskell
(9.8.2)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 173,568 KB
実行使用メモリ 27,904 KB
最終ジャッジ日時 2024-07-07 11:37:21
合計ジャッジ時間 7,940 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
14,592 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 312 ms
24,960 KB
testcase_05 AC 96 ms
13,696 KB
testcase_06 AC 106 ms
13,824 KB
testcase_07 AC 109 ms
13,952 KB
testcase_08 AC 318 ms
24,960 KB
testcase_09 AC 351 ms
27,776 KB
testcase_10 AC 124 ms
15,360 KB
testcase_11 AC 252 ms
22,016 KB
testcase_12 AC 161 ms
17,024 KB
testcase_13 AC 147 ms
16,768 KB
testcase_14 AC 287 ms
24,064 KB
testcase_15 AC 14 ms
8,448 KB
testcase_16 AC 23 ms
9,728 KB
testcase_17 AC 13 ms
8,448 KB
testcase_18 AC 17 ms
8,448 KB
testcase_19 AC 27 ms
9,984 KB
testcase_20 AC 37 ms
11,264 KB
testcase_21 AC 36 ms
10,624 KB
testcase_22 AC 65 ms
12,928 KB
testcase_23 AC 170 ms
18,304 KB
testcase_24 AC 245 ms
21,120 KB
testcase_25 AC 360 ms
27,392 KB
testcase_26 AC 366 ms
27,904 KB
testcase_27 AC 184 ms
17,536 KB
testcase_28 AC 200 ms
22,144 KB
testcase_29 AC 359 ms
27,776 KB
testcase_30 AC 356 ms
27,520 KB
testcase_31 AC 338 ms
26,624 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:3:64: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
3 | main = getContents >>= putStrLn . solve [] . sort . map read . tail . words
  |                                                                ^^^^

Main.hs:5:19: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, 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."
  |
5 | solve ls [_] = if head ls /= 0 && all (== head ls) (tail ls) then "YES" else "NO"
  |                   ^^^^

Main.hs:5:43: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘head’
    (imported from Data.List, 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."
  |
5 | solve ls [_] = if head ls /= 0 && all (== head ls) (tail ls) then "YES" else "NO"
  |                                           ^^^^

Main.hs:5:53: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
  |
5 | solve ls [_] = if head ls /= 0 && all (== head ls) (tail ls) then "YES" else "NO"
  |                                                     ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List

main = getContents >>= putStrLn . solve [] . sort . map read . tail . words

solve ls [_] = if head ls /= 0 && all (== head ls) (tail ls) then "YES" else "NO"
solve ls (a0:a1:as) = solve ((a0 - a1):ls) (a1:as)
0