結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー とりゐとりゐ
提出日時 2022-09-16 22:38:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,534 ms / 5,000 ms
コード長 646 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 259,888 KB
最終ジャッジ日時 2023-08-23 17:02:09
合計ジャッジ時間 19,919 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,240 KB
testcase_01 AC 72 ms
71,408 KB
testcase_02 AC 73 ms
71,240 KB
testcase_03 AC 75 ms
71,064 KB
testcase_04 AC 75 ms
71,124 KB
testcase_05 AC 95 ms
77,188 KB
testcase_06 AC 86 ms
77,044 KB
testcase_07 AC 3,534 ms
259,224 KB
testcase_08 AC 2,504 ms
259,288 KB
testcase_09 AC 3,055 ms
259,428 KB
testcase_10 AC 73 ms
71,264 KB
testcase_11 AC 74 ms
71,372 KB
testcase_12 AC 72 ms
71,228 KB
testcase_13 AC 71 ms
71,064 KB
testcase_14 AC 73 ms
71,340 KB
testcase_15 AC 667 ms
190,272 KB
testcase_16 AC 929 ms
258,908 KB
testcase_17 AC 533 ms
259,784 KB
testcase_18 AC 1,927 ms
259,876 KB
testcase_19 AC 535 ms
259,076 KB
testcase_20 AC 1,222 ms
259,832 KB
testcase_21 AC 74 ms
71,124 KB
testcase_22 AC 364 ms
259,888 KB
testcase_23 AC 169 ms
139,624 KB
testcase_24 AC 211 ms
155,328 KB
testcase_25 AC 270 ms
220,356 KB
testcase_26 AC 125 ms
77,888 KB
testcase_27 AC 192 ms
77,284 KB
testcase_28 AC 239 ms
178,256 KB
testcase_29 AC 306 ms
159,844 KB
testcase_30 AC 417 ms
259,392 KB
testcase_31 AC 83 ms
76,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,a,b=map(int,input().split())
s=input()

c=[]
for i in s:
  c.append(i)
  if len(c)>=3 and c[-3]+c[-2]+c[-1]=='con':
    c.pop()
    c.pop()
    c.pop()
    c.append('!')

c.append('a')
d=[]
tmp=0
for i in c:
  if i=='!':
    tmp+=1
  else:
    if tmp!=0:
      d.append(tmp)
    tmp=0

m=n
dp=[-10**9]*m
dp[0]=0
mx=0
for i in d:
  ndp=dp.copy()
  tmp=0
  while True:
    c1=tmp
    c2=(i-a*tmp)//b
    if c2<0:
      break
    for j in range(mx+1):
      ndp[j+c1]=max(ndp[j+c1],dp[j]+c2)
    tmp+=1
  mx+=c1
  dp=ndp

ans=0
#print(dp)
for i in range(1,m):
  if dp[i]>=i-1:
    ans=max(2*i-1,ans)
  if dp[i]>=i:
    ans=max(ans,2*i)

print(ans)
0