結果
問題 | No.2076 Concon Substrings (ConVersion) |
ユーザー |
![]() |
提出日時 | 2022-09-16 22:38:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,581 ms / 5,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 323 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 260,480 KB |
最終ジャッジ日時 | 2024-12-21 23:28:15 |
合計ジャッジ時間 | 19,606 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
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=0for i in c:if i=='!':tmp+=1else:if tmp!=0:d.append(tmp)tmp=0m=ndp=[-10**9]*mdp[0]=0mx=0for i in d:ndp=dp.copy()tmp=0while True:c1=tmpc2=(i-a*tmp)//bif c2<0:breakfor j in range(mx+1):ndp[j+c1]=max(ndp[j+c1],dp[j]+c2)tmp+=1mx+=c1dp=ndpans=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)