Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
---|---|---|---|---|---|---|
1735 | Codeforces Round 824 (Div. 2) | FINISHED | False | 8100 | 67101899 | Oct. 2, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 232 ) | F | Pebbles and Beads | PROGRAMMING | data structures dp geometry |
B"There are two currencies: pebbles and beads. Initially you have a pebbles, b beads. There are n days, each day you can exchange one currency for another at some exchange rate. On day i , you can exchange -p_i <= q x <= q p_i pebbles for -q_i <= q y <= q q_i beads or vice versa. It's allowed not to perform an exchange at all. Meanwhile, if you perform an exchange, the proportion x cdot q_i = -y cdot p_i must be fulfilled. Fractional exchanges are allowed. You can perform no more than one such exchange in one day. The numbers of pebbles and beads you have must always remain non-negative. Please solve the following n problems independently: for each day i , output the maximum number of pebbles that you can have at the end of day i if you perform exchanges optimally. The first line of the input contains a single integer t ( 1 <= t <= 10^3 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains three integers n , a and b ( 1 <= n <= 300 ,000 , 0 <= a, b <= 10^9 ) -- the number of days and the initial number of pebbles and beads respectively. The second line of each test case contains n integers: p_1, p_2, ldots, p_n ( 1 <= p_i <= 10^9 ). The third line of each test case contains n integers: q_1, q_2, ldots, q_n ( 1 <= q_i <= 10^9 ). It is guaranteed that the sum of n over all test cases doesn't exceed 300 ,000 . Output n numbers -- the maximum number of pebbles at the end of each day. Your answer is considered correct if its absolute or relative error does not exceed 10^{-6} . Formally, let your answer be a , and the jury's answer be b . Your answer is accepted if and only if frac{ <= ft|a - b right|}{ max(1, <= ft|b right|)} <= 10^{-6} . In the image below you can see the solutions for the first two test cases. In each line the"... |
Codeforces Round #824 — editorial |
No solutions yet.