結果
| 問題 |
No.2021 Not A but B
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-30 22:29:01 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 398 bytes |
| コンパイル時間 | 33 ms |
| コンパイル使用メモリ | 5,120 KB |
| 実行使用メモリ | 5,696 KB |
| 最終ジャッジ日時 | 2024-07-20 19:08:25 |
| 合計ジャッジ時間 | 1,465 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
local n = io.read("*n", "*l")
local s = io.read()
local ret, t = 0, {}
local org = false
for i = 1, n - 1 do
local a = s:sub(i, i) == "A"
local b = s:sub(i + 1, i + 1) == "A"
if a and b then
ret = ret + 1
elseif a then
t[i] = true
elseif b then
t[i + 1] = true
else
org = true
end
end
if org then ret = ret + 1 end
for k, v in pairs(t) do ret = ret + 1 end
print(ret)