結果
問題 |
No.2073 Concon Substrings (Swap Version)
|
ユーザー |
|
提出日時 | 2023-03-15 18:46:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 467 bytes |
コンパイル時間 | 160 ms |
コンパイル使用メモリ | 82,424 KB |
実行使用メモリ | 77,280 KB |
最終ジャッジ日時 | 2024-09-18 08:50:01 |
合計ジャッジ時間 | 3,910 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 37 |
ソースコード
n = int(input()) s = input() from collections import defaultdict d0 = defaultdict(int) d1 = defaultdict(int) d2 = defaultdict(int) for i in range(n): d0[s[3*i]] += 1 d1[s[3*i+1]] += 1 d2[s[3*i+2]] += 1 ans = 0 l = ["c","o","n"] ans1 = min(d0["c"],d1["o"],d2["n"]) ans2 = min(d0["n"],d1["c"],d2["o"]) ans3 = min(d0["o"],d1["n"],d2["c"]) if ans1 == n: print(n) exit() ans = ans1+ans2+ans3 if ans == n: print(ans-1) exit() print(ans)