結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
tak
|
| 提出日時 | 2018-06-08 07:41:33 |
| 言語 | F# (F# 10.0) |
| 結果 |
AC
|
| 実行時間 | 242 ms / 2,000 ms |
| コード長 | 520 bytes |
| 記録 | |
| コンパイル時間 | 6,124 ms |
| コンパイル使用メモリ | 206,012 KB |
| 実行使用メモリ | 67,336 KB |
| 最終ジャッジ日時 | 2026-03-20 09:02:05 |
| 合計ジャッジ時間 | 10,751 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (180 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
let S = stdin.ReadLine().ToCharArray()
let ans =
let mem = System.Collections.Generic.Dictionary<int,int>()
mem.Add(0,-1)
S
|> Array.indexed
|> Array.fold(fun (counter,maxLen) (idx,c) ->
let counter = match c with |'A' -> counter + 1 | _ -> counter - 1
match mem.TryGetValue counter with
| true, lIdx -> (counter, max maxLen (idx - lIdx))
| _ -> mem.Add(counter,idx); (counter, maxLen)) (0,0)
|> fun (counter,maxLen) -> maxLen
ans |> printfn "%i"
tak