結果

問題 No.2073 Concon Substrings (Swap Version)
コンテスト
ユーザー flygon
提出日時 2022-09-16 22:48:38
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 53 ms / 2,000 ms
+ 306µs
コード長 465 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 296 ms
コンパイル使用メモリ 64,884 KB
実行使用メモリ 59,532 KB
最終ジャッジ日時 2026-10-20 06:51:58
合計ジャッジ時間 4,666 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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
  if mn == 0: continue
  while now > 3*n:
    ans -= 1
    now -= 3 

print(ans)
0