結果
| 問題 |
No.2076 Concon Substrings (ConVersion)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-16 22:19:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,097 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 82,312 KB |
| 実行使用メモリ | 259,684 KB |
| 最終ジャッジ日時 | 2024-12-21 21:33:31 |
| 合計ジャッジ時間 | 33,300 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 TLE * 2 |
ソースコード
import sys,random,bisect
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush
from itertools import cycle, permutations
from math import log,gcd
input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())
N,X,Y = mi()
S = input()
A = []
i = 0
while i < N:
if S[i:i+3]=="con":
a = 1
j = i+3
while j+2 < len(S):
if S[j:j+3]=="con":
a += 1
j += 3
else:
break
A.append(a)
i = j
else:
i += 1
res = 0
dp = [-1] * ((N//3)*2+10)
dp[0] = 0
for a in A:
ndp = [-1] * ((N//3)*2)
for s in range(-N//3,N//3+1):
if dp[s] == -1:
continue
t = dp[s]
for k in range(a//X+1):
x = k
y = (a-k*X)//Y
ndp[s+x-y] = max(ndp[s+x-y],t+x+y)
dp = ndp
for s in range(-N//3,2):
if dp[s]!=-1:
if s <= 0:
tmp = dp[s] + s
else:
tmp = dp[s]
res = max(res,tmp)
print(res)