結果
問題 | No.2076 Concon Substrings (ConVersion) |
ユーザー |
![]() |
提出日時 | 2025-03-20 20:47:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,279 bytes |
コンパイル時間 | 248 ms |
コンパイル使用メモリ | 82,784 KB |
実行使用メモリ | 76,704 KB |
最終ジャッジ日時 | 2025-03-20 20:48:09 |
合計ジャッジ時間 | 3,180 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 6 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read().split() n = int(input[0]) A = int(input[1]) B = int(input[2]) s = input[3] # Preprocess to find all 'con' runs runs = [] i = 0 while i <= len(s) - 3: if s[i:i+3] == 'con': count = 0 j = i while j <= len(s) - 3 and s[j:j+3] == 'con': count += 1 j += 3 runs.append(count) i = j else: i += 1 # We need to process the runs dynamically considering possible overlaps after operations # But we'll use a greedy approach with the sorted list available = sorted(runs) steps = 0 current_step = 1 # 1-based steps while True: required = A if current_step % 2 == 1 else B if not available: break # Find the smallest run >= required idx = bisect.bisect_left(available, required) if idx == len(available): break # no such run selected = available.pop(idx) remaining = selected - required if remaining > 0: bisect.insort(available, remaining) steps += 1 current_step += 1 print(steps) if __name__ == '__main__': main()