結果
問題 | 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.maxlocal n = io.read("*n", "*l")local rawn = nn = n * 3local s = io.read()local x, y, z = {0,0,0},{0,0,0},{0,0,0}for i = 1, n dolocal si = s:sub(i, i)if si == "c" thenif i % 3 == 1 then x[1] = x[1] + 1elseif i % 3 == 2 then x[2] = x[2] + 1else x[3] = x[3] + 1endelseif si == "o" thenif i % 3 == 2 then y[1] = y[1] + 1elseif i % 3 == 0 then y[2] = y[2] + 1else y[3] = y[3] + 1endelseif si == "n" thenif i % 3 == 0 then z[1] = z[1] + 1elseif i % 3 == 1 then z[2] = z[2] + 1else z[3] = z[3] + 1endendendlocal 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 + clocal need = aif 0 < b + c thenneed = a + 1 + b + cendif rawn < need thenret = ret - (need - rawn)endprint(ret)