結果
問題 | No.672 最長AB列 |
ユーザー | tak |
提出日時 | 2018-06-08 07:41:33 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 124 ms / 2,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 6,205 ms |
コンパイル使用メモリ | 162,644 KB |
実行使用メモリ | 46,176 KB |
最終ジャッジ日時 | 2023-09-12 23:13:25 |
合計ジャッジ時間 | 6,829 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 81 ms
22,704 KB |
testcase_01 | AC | 83 ms
22,820 KB |
testcase_02 | AC | 81 ms
22,668 KB |
testcase_03 | AC | 80 ms
22,724 KB |
testcase_04 | AC | 80 ms
22,712 KB |
testcase_05 | AC | 82 ms
22,916 KB |
testcase_06 | AC | 80 ms
24,744 KB |
testcase_07 | AC | 80 ms
22,816 KB |
testcase_08 | AC | 82 ms
24,916 KB |
testcase_09 | AC | 124 ms
46,176 KB |
testcase_10 | AC | 117 ms
41,044 KB |
testcase_11 | AC | 119 ms
39,028 KB |
testcase_12 | AC | 114 ms
37,972 KB |
testcase_13 | AC | 118 ms
35,956 KB |
testcase_14 | AC | 113 ms
36,060 KB |
testcase_15 | AC | 113 ms
34,068 KB |
testcase_16 | AC | 113 ms
34,056 KB |
testcase_17 | AC | 117 ms
41,028 KB |
testcase_18 | AC | 111 ms
34,044 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
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"