結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2025-06-08 20:23:40 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 961 bytes |
コンパイル時間 | 692 ms |
コンパイル使用メモリ | 82,392 KB |
実行使用メモリ | 54,340 KB |
最終ジャッジ日時 | 2025-06-08 20:23:43 |
合計ジャッジ時間 | 3,416 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 15 |
ソースコード
S = list(input()) N = len(S) INF = 10**18 from bisect import bisect_left, bisect_right def cnt_ika(li, x): # x 以下の要素数 return bisect_right(li, x) def cnt_miman(li, x): # x 未満の要素数 return bisect_left(li, x) def cnt_ijou(li, x): # x 以上の要素数 return len(li) - cnt_miman(li, x) def cnt_choka(li, x): # x より大きい要素数 return len(li) - cnt_ika(li, x) c_index, w_index = [], [] for i, s in enumerate(S): if s == 'c': c_index.append(i) if s == 'w': w_index.append(i) # c を固定して、そのindex より大きい # c = [2] # w = [1, 5, 8] # 2 以下に w がいつくあるか ・・・ memo # memo + 2 番目(index: memo +2 - 1)が 右端のwのindex limit = len(w_index) ansl = [-1] for i in c_index: memo = cnt_ika(w_index, i) if memo + 1 >= limit: break utan = w_index[memo + 1] candi = utan - i + 1 ansl.append(candi) print(max(ansl))