結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2022-09-22 12:55:40 | 
| 言語 | Lua (LuaJit 2.1.1734355927) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 28 ms / 2,000 ms | 
| コード長 | 838 bytes | 
| コンパイル時間 | 194 ms | 
| コンパイル使用メモリ | 5,248 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-22 04:50:04 | 
| 合計ジャッジ時間 | 1,795 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
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)
            
            
            
        