結果
問題 | No.2076 Concon Substrings (ConVersion) |
ユーザー | 👑 rin204 |
提出日時 | 2022-09-16 22:08:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 997 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 87,064 KB |
実行使用メモリ | 78,140 KB |
最終ジャッジ日時 | 2023-08-23 15:42:28 |
合計ジャッジ時間 | 4,879 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,232 KB |
testcase_01 | AC | 76 ms
71,064 KB |
testcase_02 | AC | 76 ms
71,268 KB |
testcase_03 | AC | 76 ms
71,272 KB |
testcase_04 | AC | 76 ms
71,232 KB |
testcase_05 | WA | - |
testcase_06 | AC | 76 ms
75,424 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 74 ms
71,184 KB |
testcase_11 | AC | 74 ms
71,072 KB |
testcase_12 | WA | - |
testcase_13 | AC | 75 ms
71,516 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 75 ms
70,940 KB |
testcase_22 | WA | - |
testcase_23 | AC | 82 ms
76,356 KB |
testcase_24 | AC | 84 ms
76,144 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 84 ms
76,252 KB |
testcase_31 | WA | - |
ソースコード
from heapq import * n, a, b = map(int, input().split()) S = input() S = S.replace("con", "*") lst = [] row = 0 for s in S: if s == "*": row += 1 else: if row != 0: lst.append(row) row = 0 if row != 0: lst.append(row) lst.sort() tot = sum(lst) c = 0 d = 0 C = [] for l in lst: c += l // a l %= a d += l // b l %= b C.append(-l) C.sort() def ok(x): aa = (x + 1) // 2 bb = x - aa ab = aa * a + bb * b if ab > tot: return False if c < aa: return False elif d >= bb: return True cc = c - aa dd = bb - d hq = C[:] for _ in range(cc): k = -heappop(hq) k += a dd -= k // bb k %= bb if dd <= 0: return True k %= b heappush(hq, -k) return dd <= 0 l = 0 r = n + 1 while r - l > 1: mid = (l + r) // 2 if ok(mid): l = mid else: r = mid print(l)