結果
| 問題 | No.672 最長AB列 | 
| コンテスト | |
| ユーザー |  horiesiniti | 
| 提出日時 | 2018-05-12 17:05:03 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 708 bytes | 
| コンパイル時間 | 163 ms | 
| コンパイル使用メモリ | 148,864 KB | 
| 最終ジャッジ日時 | 2024-06-28 09:37:13 | 
| 合計ジャッジ時間 | 964 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:1:1: error: [GHC-87110]
    Could not load module ‘Data.Map’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
1 | import qualified Data.Map as M
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            
            ソースコード
import qualified Data.Map as M
import qualified Control.Applicative as CA
f :: (Int,Int) -> Char -> (Int,Int)
f (a,p) c
   |c=='A' =(a+1,p+1)
   |otherwise=(a-1,p+1)
toM1 :: (Ord k)=>[(k,Int)]->M.Map k Int
toM1 xs = M.fromListWith up xs
         where up n1 n2=n1
toM2 :: (Ord k)=>[(k,Int)]->M.Map k Int
toM2 xs = M.fromListWith up xs
         where up n1 n2=n2
f2 (Just x)=x
f2 Nothing =0 
main=do
      x<-getLine
      let ys=scanl f (0,0) x
          as=toM1 ys
          bs=toM2 ys
          cs=M.keys as
          ds=map (\x -> (M.lookup x as)) cs
          es=map (\x -> (M.lookup x bs)) cs
          fs=zip ds es
          ans=maximum $ fmap (\(a,b)->CA.liftA2 (-) a b) fs
      print $ f2 $ ans
            
            
            
        