結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー googol_S0
提出日時 2022-09-16 21:41:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,540 KB
最終ジャッジ日時 2024-12-21 18:47:28
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

N,A,B=map(int,input().split())
if A>B:
  A,B=B,A
S=input()
i=0
C=[0]
while i+2<len(S):
  if S[i]=='c' and S[i+1]=='o' and S[i+2]=='n':
    C[-1]+=1
    i+=3
  else:
    C.append(0)
    i+=1
from heapq import *
Q=[(-(C[i]%B),C[i]) for i in range(len(C))]
heapify(Q)
P=sum([C[i]//B for i in range(len(C))])
ANS=0
while len(Q):
  v=heappop(Q)
  if v[1]<A:
    continue
  if P==0 and v[0]<A:
    continue
  w=-v[0]
  if w<A:
    P-=1
  w=(w-A)%B
  ANS+=1
  heappush(Q,(w,v[1]-A))
  if P>0:
    P-=1
    ANS+=1
  else:
    break
print(ANS)
0