結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-04-20 17:31:27 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 401 bytes |
コンパイル時間 | 384 ms |
コンパイル使用メモリ | 5,504 KB |
実行使用メモリ | 9,420 KB |
最終ジャッジ日時 | 2024-06-27 20:25:35 |
合計ジャッジ時間 | 988 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
local ffi = require 'ffi' print((function (s, ct) local h,t,r = {[0]=ct(0,-1)},0,0 local m = math.floor(#s/2) for i=1,#s do t = s:sub(i,i)=="A" and t+1 or t-1 if t<=m and -m<=t then if h[t] == nil then h[t]=ct(i,-1) else h[t].r=i end end end for _,v in pairs(h) do if v.r~=-1 and v.r-v.l>r then r=v.r-v.l end end return r end)(io.stdin:read("*l"), ffi.typeof("struct { int l; int r; }")))