結果
問題 | No.2076 Concon Substrings (ConVersion) |
ユーザー |
![]() |
提出日時 | 2022-09-16 22:38:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,604 ms / 5,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 179 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 260,540 KB |
最終ジャッジ日時 | 2025-06-20 00:39:25 |
合計ジャッジ時間 | 18,758 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
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)