結果
| 問題 | No.2073 Concon Substrings (Swap Version) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-09-16 22:48:38 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 81 ms / 2,000 ms | 
| コード長 | 465 bytes | 
| コンパイル時間 | 194 ms | 
| コンパイル使用メモリ | 82,688 KB | 
| 実行使用メモリ | 76,672 KB | 
| 最終ジャッジ日時 | 2024-12-21 22:07:04 | 
| 合計ジャッジ時間 | 3,803 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 37 | 
ソースコード
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)
            
            
            
        