結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー flygon
提出日時 2022-09-16 22:45:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,928 KB
最終ジャッジ日時 2024-12-21 22:04:51
合計ジャッジ時間 3,768 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 31 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = input()
pos = [[0]*3 for i in range(3)]
for i,c in enumerate(s):
  if c == "c":
    pos[0][i%3] += 1
  elif c == "o":
    pos[1][i%3] += 1
  elif c == "n":
    pos[2][i%3] += 1

now = 0
ans = 0

for i in range(3):
  while now % 3 != i:
    now += 1
  
  cc,oo,nn = pos[0][(0+i)%3], pos[1][(1+i)%3], pos[2][(2+i)%3]
  mn = min(cc,oo,nn)
  now += mn * 3
  ans += mn
  while now >= 3*n:
    ans -= 1
    now -= 3 

print(ans)
0