結果
問題 | 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] += 1elif c == "o":pos[1][i%3] += 1elif c == "n":pos[2][i%3] += 1now = 0ans = 0for i in range(3):while now % 3 != i:now += 1cc,oo,nn = pos[0][(0+i)%3], pos[1][(1+i)%3], pos[2][(2+i)%3]mn = min(cc,oo,nn)now += mn * 3ans += mnif mn == 0: continuewhile now > 3*n:ans -= 1now -= 3print(ans)