提出 #17917533
ソースコード 拡げる
{-# LANGUAGE FlexibleContexts #-}
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.IntMap.Strict as M
import qualified Data.IntSet as S
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
main = sub =<< get
sub [n,c] = sol n c <$> get3N n >>= print
get = unfoldr (C.readInt . C.dropWhile (<'+')) <$> C.getLine
get3N n = V.replicateM n $ U.unfoldrN 3 (C.readInt . C.dropWhile (<'+')) <$> C.getLine
sol n c = maximum . scanl1 (+)
. fmap snd . M.toAscList
. M.foldrWithKey' h M.empty
. M.filter (not . S.null) . M.map g
. V.foldr f M.empty
f stc = M.insertWith S.union t (S.singleton (-c)) . M.insertWith S.union s (S.singleton c)
where
s = stc U.! 0
t = stc U.! 1
c = stc U.! 2
g cs = S.foldr' g' cs cs
where
g' c s = if c>0 && S.member (-c) s then S.delete c $ S.delete (-c) s else s
h k cs m = S.foldr' h' m cs :: M.IntMap Int
where
h' c = if c>0 then M.insertWith (+) (k-1) 1 else M.insertWith (+) k (-1)
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Recording |
| ユーザ | karoyakani |
| 言語 | Haskell (GHC 8.8.3) |
| 得点 | 400 |
| コード長 | 1031 Byte |
| 結果 | AC |
| 実行時間 | 313 ms |
| メモリ | 47040 KiB |
コンパイルエラー
Loaded package environment from /home/contestant/.ghc/x86_64-linux-8.8.3/environments/default
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample_01.txt, sample_02.txt, sample_03.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 313 ms | 41908 KiB |
| 02.txt | AC | 302 ms | 41956 KiB |
| 03.txt | AC | 305 ms | 41836 KiB |
| 04.txt | AC | 272 ms | 41832 KiB |
| 05.txt | AC | 238 ms | 47040 KiB |
| 06.txt | AC | 140 ms | 27508 KiB |
| 07.txt | AC | 103 ms | 22572 KiB |
| 08.txt | AC | 7 ms | 5288 KiB |
| 09.txt | AC | 301 ms | 41980 KiB |
| 10.txt | AC | 294 ms | 41972 KiB |
| 11.txt | AC | 287 ms | 41948 KiB |
| 12.txt | AC | 2 ms | 4196 KiB |
| 13.txt | AC | 3 ms | 4044 KiB |
| 14.txt | AC | 2 ms | 4148 KiB |
| 15.txt | AC | 2 ms | 4032 KiB |
| 16.txt | AC | 287 ms | 41920 KiB |
| 17.txt | AC | 275 ms | 41772 KiB |
| 18.txt | AC | 293 ms | 41836 KiB |
| 19.txt | AC | 289 ms | 41976 KiB |
| sample_01.txt | AC | 2 ms | 3984 KiB |
| sample_02.txt | AC | 3 ms | 3912 KiB |
| sample_03.txt | AC | 2 ms | 4080 KiB |