{"problem":{"name":"B. Producing Snow","description":{"content":"Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amoun","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF923B"},"statements":[{"statement_type":"Markdown","content":"Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day _i_ he will make a pile of snow of volume _V__i_ and put it in her garden.\n\nEach day, every pile will shrink a little due to melting. More precisely, when the temperature on a given day is _T__i_, each pile will reduce its volume by _T__i_. If this would reduce the volume of a pile to or below zero, it disappears forever. All snow piles are independent of each other.\n\nNote that the pile made on day _i_ already loses part of its volume on the same day. In an extreme case, this may mean that there are no piles left at the end of a particular day.\n\nYou are given the initial pile sizes and the temperature on each day. Determine the total volume of snow melted on each day.\n\n## Input\n\nThe first line contains a single integer _N_ (1 ≤ _N_ ≤ 105) — the number of days.\n\nThe second line contains _N_ integers _V_1, _V_2, ..., _V__N_ (0 ≤ _V__i_ ≤ 109), where _V__i_ is the initial size of a snow pile made on the day _i_.\n\nThe third line contains _N_ integers _T_1, _T_2, ..., _T__N_ (0 ≤ _T__i_ ≤ 109), where _T__i_ is the temperature on the day _i_.\n\n## Output\n\nOutput a single line with _N_ integers, where the _i_\\-th integer represents the total volume of snow melted on day _i_.\n\n[samples]\n\n## Note\n\nIn the first sample, Bob first makes a snow pile of volume 10, which melts to the size of 5 on the same day. On the second day, he makes another pile of size 10. Since it is a bit warmer than the day before, the first pile disappears completely while the second pile shrinks to 3. At the end of the second day, he has only a single pile of size 3. On the third day he makes a smaller pile than usual, but as the temperature dropped too, both piles survive till the end of the day.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Alice 非常喜欢雪！但不幸的是，今年的冬天已经结束，她再也无法期待更多的雪了。因此，Bob 给她买了一份礼物——一个大型造雪机。他计划每天制造一定量的雪。在第 #cf_span[i] 天，他会制造一个体积为 #cf_span[Vi] 的雪堆，并将其放在她的花园里。\n\n每天，每个雪堆都会因融化而略微变小。更准确地说，当某天的温度为 #cf_span[Ti] 时，每个雪堆的体积会减少 #cf_span[Ti]。如果这会使某个雪堆的体积减少到零或以下，则该雪堆会永久消失。所有雪堆彼此独立。\n\n请注意，第 #cf_span[i] 天制造的雪堆在同一天也会部分融化。极端情况下，这可能导致某天结束时没有任何雪堆剩下。\n\n给你每个雪堆的初始体积和每天的温度，请确定每天融化的雪的总体积。\n\n第一行包含一个整数 #cf_span[N] (#cf_span[1 ≤ N ≤ 105]) —— 天数。\n\n第二行包含 #cf_span[N] 个整数 #cf_span[V1, V2, ..., VN] (#cf_span[0 ≤ Vi ≤ 109])，其中 #cf_span[Vi] 是第 #cf_span[i] 天制造的雪堆的初始体积。\n\n第三行包含 #cf_span[N] 个整数 #cf_span[T1, T2, ..., TN] (#cf_span[0 ≤ Ti ≤ 109])，其中 #cf_span[Ti] 是第 #cf_span[i] 天的温度。\n\n请输出一行包含 #cf_span[N] 个整数，其中第 #cf_span[i] 个整数表示第 #cf_span[i] 天融化的雪的总体积。\n\n在第一个样例中，Bob 首先制造了一个体积为 10 的雪堆，该雪堆在当天融化至体积 5。第二天，他又制造了一个体积为 10 的雪堆。由于当天比前一天稍暖，第一个雪堆完全消失，而第二个雪堆缩小至 3。第二天结束时，他只剩下一个体积为 3 的雪堆。第三天他制造了一个比平时小的雪堆，但温度也下降了，因此两个雪堆都存活到了当天结束。\n\n## Input\n\n第一行包含一个整数 #cf_span[N] (#cf_span[1 ≤ N ≤ 105]) —— 天数。第二行包含 #cf_span[N] 个整数 #cf_span[V1, V2, ..., VN] (#cf_span[0 ≤ Vi ≤ 109])，其中 #cf_span[Vi] 是第 #cf_span[i] 天制造的雪堆的初始体积。第三行包含 #cf_span[N] 个整数 #cf_span[T1, T2, ..., TN] (#cf_span[0 ≤ Ti ≤ 109])，其中 #cf_span[Ti] 是第 #cf_span[i] 天的温度。\n\n## Output\n\n请输出一行包含 #cf_span[N] 个整数，其中第 #cf_span[i] 个整数表示第 #cf_span[i] 天融化的雪的总体积。\n\n[samples]\n\n## Note\n\n在第一个样例中，Bob 首先制造了一个体积为 10 的雪堆，该雪堆在当天融化至体积 5。第二天，他又制造了一个体积为 10 的雪堆。由于当天比前一天稍暖，第一个雪堆完全消失，而第二个雪堆缩小至 3。第二天结束时，他只剩下一个体积为 3 的雪堆。第三天他制造了一个比平时小的雪堆，但温度也下降了，因此两个雪堆都存活到了当天结束。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ N \\in \\mathbb{Z}^+ $ be the number of days.  \nLet $ V = (V_1, V_2, \\dots, V_N) \\in \\mathbb{R}^N $ be the initial volumes of snow piles made each day.  \nLet $ T = (T_1, T_2, \\dots, T_N) \\in \\mathbb{R}^N $ be the daily temperatures.  \n\nFor each day $ i \\in \\{1, \\dots, N\\} $, let $ S_i $ be the set of snow piles present at the start of day $ i $:  \n$$ S_i = \\{ V_j \\mid j \\in \\{1, \\dots, i\\} \\text{ and } \\sum_{k=j}^{i-1} T_k < V_j \\} $$  \nEach pile $ V_j \\in S_i $ melts by $ \\min(V_j - \\sum_{k=j}^{i-1} T_k, T_i) $ on day $ i $.  \n\n**Constraints**  \n1. $ 1 \\leq N \\leq 10^5 $  \n2. $ 0 \\leq V_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, N\\} $  \n3. $ 0 \\leq T_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, N\\} $  \n\n**Objective**  \nFor each day $ i \\in \\{1, \\dots, N\\} $, compute the total melted volume $ M_i $:  \n$$ M_i = \\sum_{j=1}^{i} \\min\\left( \\max\\left(0, V_j - \\sum_{k=j}^{i-1} T_k \\right), T_i \\right) $$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF923B","tags":["binary search","data structures"],"sample_group":[["3\n10 10 5\n5 7 2","5 12 4"],["5\n30 25 20 15 10\n9 10 12 4 13","9 20 35 11 25"]],"created_at":"2026-03-03 11:00:39"}}