結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー googol_S0googol_S0
提出日時 2022-09-16 21:41:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 534 bytes
コンパイル時間 1,349 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 79,284 KB
最終ジャッジ日時 2023-08-23 14:41:14
合計ジャッジ時間 6,354 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 74 ms
71,176 KB
testcase_02 AC 76 ms
71,116 KB
testcase_03 AC 75 ms
70,916 KB
testcase_04 AC 79 ms
71,228 KB
testcase_05 AC 86 ms
76,024 KB
testcase_06 AC 81 ms
75,660 KB
testcase_07 AC 116 ms
78,104 KB
testcase_08 AC 152 ms
78,956 KB
testcase_09 AC 114 ms
78,104 KB
testcase_10 WA -
testcase_11 AC 74 ms
71,104 KB
testcase_12 AC 77 ms
71,336 KB
testcase_13 AC 76 ms
71,340 KB
testcase_14 WA -
testcase_15 AC 107 ms
76,884 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 137 ms
78,268 KB
testcase_21 AC 75 ms
70,960 KB
testcase_22 AC 124 ms
77,452 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 128 ms
77,664 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

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