結果

問題 No.672 最長AB列
ユーザー nobigomunobigomu
提出日時 2018-04-20 12:27:52
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 282 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 5,268 KB
実行使用メモリ 17,028 KB
最終ジャッジ日時 2023-09-10 04:44:24
合計ジャッジ時間 1,641 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,388 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 36 ms
17,028 KB
testcase_10 AC 21 ms
9,728 KB
testcase_11 AC 69 ms
12,044 KB
testcase_12 AC 19 ms
4,788 KB
testcase_13 AC 33 ms
5,176 KB
testcase_14 AC 16 ms
5,100 KB
testcase_15 AC 17 ms
5,116 KB
testcase_16 AC 23 ms
4,760 KB
testcase_17 AC 73 ms
11,828 KB
testcase_18 AC 29 ms
4,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

print((function (s)
	local h,t,r = {[0]={0}},0,0

	for i=1,#s do
		t = s:sub(i,i)=="A" and t+1 or t-1
		if h[t] == nil then h[t]={i} else table.insert(h[t],i) end
	end
	for _,v in pairs(h) do if #v>1 and v[#v]-v[1]>r then r = v[#v]-v[1] end end

	return r
end)(io.stdin:read("*l")))
0