<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>h0rnet</author_name>
  <author_url>https://blog.hatena.ne.jp/h0rnet/</author_url>
  <blog_title>0w1</blog_title>
  <blog_url>https://h0rnet.hatenablog.com/</blog_url>
  <categories>
    <anon>Codeforces</anon>
    <anon>Bracket Sequence</anon>
    <anon>Greedy</anon>
  </categories>
  <description>Problem - D - Codeforces題意： 給一個序列，有 '(', ')', '?' 三種符號，每個 '?' 有相應的代價可以轉換成左括弧或右括弧，求最小總代價，使得變成合法的括弧序列，或者判斷不存在合法的方案。資料規模： 序列長度 1 ≤ N ≤ 5e4 轉換代價 1 ≤ A[ i ], B[ i ] ≤ 1e6 時間限制：500 ms 空間限制：64 MB解法： 顯然不能 DP。考慮貪婪法。由左到右掃描，如果某個時機左括弧總數量小於右括弧的數量，那麼必須要把在這之前可改的右括弧變成左括弧。但任意時機右括弧少於左括弧沒關係。因此考慮先把所有 '?' 轉換成右括弧，有左到右掃描，…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fh0rnet.hatenablog.com%2Fentry%2F2017%2F01%2F11%2FCFR_3_D__Least_Cost_Bracket_Sequence_%2528_Greedy_%2529&quot; title=&quot;CFR 3 D. Least Cost Bracket Sequence ( Greedy ) - 0w1&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2017-01-11 15:01:43</published>
  <title>CFR 3 D. Least Cost Bracket Sequence ( Greedy )</title>
  <type>rich</type>
  <url>https://h0rnet.hatenablog.com/entry/2017/01/11/CFR_3_D__Least_Cost_Bracket_Sequence_%28_Greedy_%29</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
