結果
| 問題 |
No.2076 Concon Substrings (ConVersion)
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:27:13 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,323 bytes |
| コンパイル時間 | 367 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 74,404 KB |
| 最終ジャッジ日時 | 2025-06-12 16:27:31 |
| 合計ジャッジ時間 | 2,556 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 19 |
ソースコード
def parse_runs(s):
runs = []
n = len(s)
i = 0
while i < n:
if s[i] == 'c' and i + 2 < n and s[i+1] == 'o' and s[i+2] == 'n':
count = 0
j = i
while j + 2 < n and s[j] == 'c' and s[j+1] == 'o' and s[j+2] == 'n':
count += 1
j += 3
runs.append(count)
i = j
else:
i += 1
return runs
def compute_max_steps(K, A, B):
if A == 0 or B == 0:
return 0
low = 0
high = 2 * K # An upper bound for the number of steps
best = 0
while low <= high:
mid = (low + high) // 2
sum_needed = 0
t = mid // 2
if mid % 2 == 0:
sum_needed = t * (A + B)
else:
sum_needed = t * (A + B) + A
if sum_needed <= K:
best = mid
low = mid + 1
else:
high = mid - 1
return best
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx])
idx += 1
A = int(input[idx])
idx += 1
B = int(input[idx])
idx += 1
S = input[idx]
idx += 1
runs = parse_runs(S)
total = 0
for K in runs:
m = compute_max_steps(K, A, B)
total += m
print(total)
if __name__ == "__main__":
main()
gew1fw