結果

問題 No.1 道のショートカット
ユーザー aimyaimy
提出日時 2017-05-03 16:54:23
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 7,436 ms
コンパイル使用メモリ 161,520 KB
実行使用メモリ 13,912 KB
最終ジャッジ日時 2023-09-22 13:07:40
合計ジャッジ時間 9,448 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,608 KB
testcase_01 AC 3 ms
7,620 KB
testcase_02 AC 3 ms
7,624 KB
testcase_03 AC 3 ms
7,664 KB
testcase_04 AC 3 ms
7,540 KB
testcase_05 AC 3 ms
7,560 KB
testcase_06 AC 3 ms
7,816 KB
testcase_07 AC 3 ms
7,908 KB
testcase_08 AC 22 ms
13,304 KB
testcase_09 AC 12 ms
12,612 KB
testcase_10 AC 22 ms
13,296 KB
testcase_11 AC 22 ms
13,424 KB
testcase_12 WA -
testcase_13 AC 22 ms
13,912 KB
testcase_14 WA -
testcase_15 AC 3 ms
7,340 KB
testcase_16 WA -
testcase_17 AC 2 ms
7,584 KB
testcase_18 AC 4 ms
9,536 KB
testcase_19 AC 4 ms
8,896 KB
testcase_20 AC 12 ms
11,756 KB
testcase_21 AC 5 ms
10,012 KB
testcase_22 AC 4 ms
8,852 KB
testcase_23 AC 22 ms
13,460 KB
testcase_24 AC 22 ms
13,256 KB
testcase_25 AC 12 ms
11,804 KB
testcase_26 AC 6 ms
11,004 KB
testcase_27 AC 22 ms
13,416 KB
testcase_28 AC 3 ms
7,704 KB
testcase_29 AC 22 ms
13,824 KB
testcase_30 AC 8 ms
11,784 KB
testcase_31 AC 12 ms
12,336 KB
testcase_32 WA -
testcase_33 AC 12 ms
12,348 KB
testcase_34 WA -
testcase_35 AC 23 ms
12,612 KB
testcase_36 WA -
testcase_37 AC 22 ms
12,688 KB
testcase_38 AC 4 ms
8,704 KB
testcase_39 AC 5 ms
9,924 KB
testcase_40 WA -
testcase_41 AC 5 ms
9,736 KB
testcase_42 AC 3 ms
7,556 KB
testcase_43 AC 3 ms
7,364 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 Data.IntMap ((!))
import qualified Data.IntMap as M
import Data.List

main = do
 n <- readLn
 c <- readLn
 getLine
 styms <- transpose . map (map read . words) . lines <$> getContents
 print (shortcut n c styms)

shortcut n c = snd . M.findWithDefault (-1,-1) n . foldl (move n) (M.singleton 1 (c,0)) . sort

move n im [s,t,y,m]
 | not (M.member s im) = im
 | y'-y < 0 = im
 | otherwise = M.insertWith eval t (y'-y,m'+m) im
 where
  (y',m') = im!s
  eval (y1,m1) (y2,m2)
   | m2 <= m1 = (y2,m2)
   | otherwise = (y1,m1)
0