結果

問題 No.365 ジェンガソート
ユーザー momen999momen999
提出日時 2017-08-01 08:10:13
言語 Haskell
(9.8.2)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 252 bytes
コンパイル時間 9,136 ms
コンパイル使用メモリ 175,616 KB
実行使用メモリ 82,944 KB
最終ジャッジ日時 2024-10-11 05:45:04
合計ジャッジ時間 14,348 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 1 ms
6,816 KB
testcase_03 AC 2 ms
6,820 KB
testcase_04 AC 1 ms
6,816 KB
testcase_05 AC 2 ms
6,816 KB
testcase_06 AC 2 ms
6,816 KB
testcase_07 AC 1 ms
6,816 KB
testcase_08 AC 2 ms
6,816 KB
testcase_09 AC 1 ms
6,816 KB
testcase_10 AC 2 ms
6,820 KB
testcase_11 AC 2 ms
6,816 KB
testcase_12 AC 2 ms
6,816 KB
testcase_13 AC 2 ms
6,816 KB
testcase_14 AC 2 ms
6,816 KB
testcase_15 AC 2 ms
6,820 KB
testcase_16 AC 283 ms
48,640 KB
testcase_17 AC 327 ms
65,920 KB
testcase_18 AC 26 ms
12,416 KB
testcase_19 AC 309 ms
64,640 KB
testcase_20 AC 97 ms
24,832 KB
testcase_21 AC 79 ms
21,248 KB
testcase_22 AC 253 ms
48,512 KB
testcase_23 AC 156 ms
39,424 KB
testcase_24 AC 240 ms
47,744 KB
testcase_25 AC 71 ms
21,120 KB
testcase_26 AC 199 ms
43,776 KB
testcase_27 AC 371 ms
81,152 KB
testcase_28 AC 210 ms
46,720 KB
testcase_29 AC 288 ms
53,760 KB
testcase_30 AC 217 ms
46,592 KB
testcase_31 AC 93 ms
24,064 KB
testcase_32 AC 93 ms
24,064 KB
testcase_33 AC 377 ms
80,000 KB
testcase_34 AC 65 ms
18,944 KB
testcase_35 AC 256 ms
47,744 KB
testcase_36 AC 367 ms
82,944 KB
testcase_37 AC 370 ms
82,816 KB
testcase_38 AC 375 ms
82,816 KB
testcase_39 AC 364 ms
82,560 KB
testcase_40 AC 367 ms
82,560 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:4:7: 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."
  |
4 |     | head xs == n  = jenga (n - 1) (tail xs)
  |       ^^^^

Main.hs:4:38: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, 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."
  |
4 |     | head xs == n  = jenga (n - 1) (tail xs)
  |                                      ^^^^

Main.hs:5:32: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Prelude, 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 |     | otherwise     = jenga n (tail xs)
  |                                ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

jenga :: Int -> [Int] -> Int
jenga n xs
    | null xs       = n
    | head xs == n  = jenga (n - 1) (tail xs)
    | otherwise     = jenga n (tail xs)
    
main = do
    n <- readLn
    xs <- map read . words <$> getLine
    print $ jenga n (reverse xs)
0