結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー 👑 obakyanobakyan
提出日時 2022-09-22 12:55:40
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 41 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 20:30:55
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 13 ms
4,380 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 11 ms
4,376 KB
testcase_10 AC 25 ms
4,376 KB
testcase_11 AC 24 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 21 ms
4,380 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 17 ms
4,384 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 16 ms
4,376 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 10 ms
4,380 KB
testcase_22 AC 17 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 11 ms
4,380 KB
testcase_26 AC 17 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 14 ms
4,376 KB
testcase_29 AC 5 ms
4,380 KB
testcase_30 AC 13 ms
4,376 KB
testcase_31 AC 7 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 10 ms
4,380 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 10 ms
4,380 KB
testcase_38 AC 4 ms
4,376 KB
testcase_39 AC 11 ms
4,376 KB
testcase_40 AC 10 ms
4,380 KB
testcase_41 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
local rawn = n
n = n * 3
local s = io.read()
local x, y, z = {0,0,0},{0,0,0},{0,0,0}
for i = 1, n do
  local si = s:sub(i, i)
  if si == "c" then
    if i % 3 == 1 then x[1] = x[1] + 1
    elseif i % 3 == 2 then x[2] = x[2] + 1
    else x[3] = x[3] + 1
    end
  elseif si == "o" then
    if i % 3 == 2 then y[1] = y[1] + 1
    elseif i % 3 == 0 then y[2] = y[2] + 1
    else y[3] = y[3] + 1
    end
  elseif si == "n" then
    if i % 3 == 0 then z[1] = z[1] + 1
    elseif i % 3 == 1 then z[2] = z[2] + 1
    else z[3] = z[3] + 1
    end
  end
end
local a, b, c = mmi(x[1],y[1],z[1]), mmi(x[2],y[2],z[2]), mmi(x[3],y[3],z[3])
local ret = a + b + c
local need = a
if 0 < b + c then
  need = a + 1 + b + c
end
if rawn < need then
  ret = ret - (need - rawn)
end
print(ret)
0