結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 251 ms
48,512 KB
testcase_17 AC 303 ms
65,792 KB
testcase_18 AC 25 ms
12,160 KB
testcase_19 AC 302 ms
64,640 KB
testcase_20 AC 93 ms
24,960 KB
testcase_21 AC 70 ms
20,992 KB
testcase_22 AC 237 ms
48,768 KB
testcase_23 AC 145 ms
39,296 KB
testcase_24 AC 222 ms
47,616 KB
testcase_25 AC 65 ms
20,864 KB
testcase_26 AC 180 ms
43,520 KB
testcase_27 AC 340 ms
81,152 KB
testcase_28 AC 187 ms
46,592 KB
testcase_29 AC 262 ms
53,760 KB
testcase_30 AC 195 ms
46,592 KB
testcase_31 AC 80 ms
23,936 KB
testcase_32 AC 77 ms
23,936 KB
testcase_33 AC 337 ms
79,744 KB
testcase_34 AC 52 ms
18,560 KB
testcase_35 AC 222 ms
47,744 KB
testcase_36 AC 340 ms
82,688 KB
testcase_37 AC 344 ms
82,688 KB
testcase_38 AC 345 ms
82,688 KB
testcase_39 AC 337 ms
82,688 KB
testcase_40 AC 448 ms
82,816 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