結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー |
![]() |
提出日時 | 2023-01-27 23:07:48 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 749 bytes |
コンパイル時間 | 222 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 105,036 KB |
最終ジャッジ日時 | 2024-06-28 07:58:51 |
合計ジャッジ時間 | 5,162 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 29 WA * 8 |
ソースコード
from collections import *N = int(input())S = list(input())D = [defaultdict(int) for i in range(3)]for i in range(3*N):D[i%3][S[i]] += 1L = [0, 0, 0]L[0] = min(D[0]["c"], D[1]["o"], D[2]["n"])L[1] = min(D[0]["n"], D[1]["c"], D[2]["o"])L[2] = min(D[0]["o"], D[1]["n"], D[2]["c"])# print(L)# print(D)ans = 0N *= 3if N >= 3 * L[0]:ans += L[0]if L[0]:N -= 3 * L[0] + 1N = max(0, N)else:print(ans + N//3)exit()if N >= 3 * L[1]:ans += L[1]if L[1]:N -= 3 * L[1] + 1N = max(0, N)else:print(ans + N//3)exit()if N >= 3 * L[2]:ans += L[2]if L[2]:N -= 3 * L[2] + 1N = max(0, N)else:print(ans + N//3)exit()print(ans)