結果
問題 | No.672 最長AB列 |
ユーザー | tak |
提出日時 | 2018-06-08 08:18:49 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 434 ms / 2,000 ms |
コード長 | 413 bytes |
コンパイル時間 | 5,088 ms |
コンパイル使用メモリ | 153,832 KB |
実行使用メモリ | 39,680 KB |
最終ジャッジ日時 | 2023-09-12 23:13:03 |
合計ジャッジ時間 | 9,223 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 85 ms
25,004 KB |
testcase_01 | AC | 85 ms
25,020 KB |
testcase_02 | AC | 85 ms
25,020 KB |
testcase_03 | AC | 84 ms
22,976 KB |
testcase_04 | AC | 86 ms
25,004 KB |
testcase_05 | AC | 86 ms
22,880 KB |
testcase_06 | AC | 85 ms
23,048 KB |
testcase_07 | AC | 86 ms
22,884 KB |
testcase_08 | AC | 85 ms
23,008 KB |
testcase_09 | AC | 434 ms
39,252 KB |
testcase_10 | AC | 310 ms
37,764 KB |
testcase_11 | AC | 313 ms
35,664 KB |
testcase_12 | AC | 155 ms
36,080 KB |
testcase_13 | AC | 158 ms
36,200 KB |
testcase_14 | AC | 158 ms
34,164 KB |
testcase_15 | AC | 160 ms
34,160 KB |
testcase_16 | AC | 156 ms
34,092 KB |
testcase_17 | AC | 312 ms
39,680 KB |
testcase_18 | AC | 128 ms
36,160 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
stdin.ReadLine().ToCharArray() |> Array.indexed |> Array.fold(fun (mem,counter,maxLen) (idx,c) -> let counter = match c with |'A' -> counter + 1 | _ -> counter - 1 match Map.containsKey counter mem with | true -> (mem, counter, (max maxLen (idx - mem.[counter]))) | _ -> ((mem.Add(counter,idx)), counter, maxLen)) (Map.ofList[0,-1],0,0) |> fun (_,_,maxLen) -> printfn "%i" maxLen