結果

問題 No.674 n連勤
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-15 19:03:30
言語 Haskell
(9.8.2)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,126 ms
コンパイル使用メモリ 165,872 KB
実行使用メモリ 60,260 KB
最終ジャッジ日時 2023-09-09 06:55:59
合計ジャッジ時間 4,963 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,196 KB
testcase_01 AC 2 ms
7,500 KB
testcase_02 AC 3 ms
7,152 KB
testcase_03 AC 3 ms
7,308 KB
testcase_04 AC 3 ms
7,252 KB
testcase_05 AC 2 ms
7,476 KB
testcase_06 AC 3 ms
7,396 KB
testcase_07 AC 3 ms
7,472 KB
testcase_08 AC 3 ms
7,248 KB
testcase_09 AC 3 ms
7,328 KB
testcase_10 AC 3 ms
7,492 KB
testcase_11 AC 22 ms
13,288 KB
testcase_12 AC 32 ms
13,264 KB
testcase_13 AC 283 ms
47,524 KB
testcase_14 AC 312 ms
51,572 KB
testcase_15 AC 272 ms
47,416 KB
testcase_16 AC 423 ms
60,260 KB
testcase_17 AC 402 ms
60,156 KB
testcase_18 AC 313 ms
47,432 KB
testcase_19 AC 303 ms
51,460 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 Control.Monad
import qualified Data.Map.Strict as M
extendS s m
  | Just (k,v) <- M.lookupLT s m, v >= s-1 = k
  | otherwise = s
extendE e m
  | Just (k,v) <- M.lookupLE (e+1) m, v > e = v
  | otherwise = e
deleteR s e m
  | Just (k,v) <- M.lookupGE s m, v <= e = deleteR s e (M.delete k m)
  | otherwise = m
solve (x,m) [a,b] = (max x (e-s+1), M.insert s e $ deleteR s e m)
  where s = extendS a m
        e = extendE b m
main = do
  [d,q] <- map read . words <$> getLine
  qs <- replicateM q $ map read . words <$> getLine
  mapM_ (print . fst) $ tail $ scanl solve (0,M.empty) qs
0