Codeforces Round 982 (Div. 2)

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
2027 Codeforces Round 982 (Div. 2) FINISHED False 7200 46452323 Oct. 26, 2024, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 6929 ) D1 The Endspeaker (Easy Version) PROGRAMMING binary search dp graphs greedy implementation two pointers

This is the easy version of this problem. The only difference is that you only need to output the minimum total cost of operations in this version. You must solve both versions to be able to hack. You're given an array (a) of length (n), and an array (b) of length (m) ((b_i > b_{i+1}) for all (1 \le i < m)). Initially, the value of (k) is (1). Your aim is to make the array (a) empty by performing one of these two operations repeatedly: Type (1) — If the value of (k) is less than (m) and the array (a) is not empty , you can increase the value of (k) by (1). This does not incur any cost. Type (2) — You remove a non-empty prefix of array (a), such that its sum does not exceed (b_k). This incurs a cost of (m - k). You need to minimize the total cost of the operations to make array (a) empty. If it's impossible to do this through any sequence of operations, output (-1). Otherwise, output the minimum total cost of the operations. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 1000)). The description of the test cases follows. The first line of each test case contains two integers (n) and (m) ((1 \le n, m \le 3 \cdot 10^5), (\boldsymbol{1 \le n \cdot m \le 3 \cdot 10^5})). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((1 \le a_i \le 10^9)). The third line of each test case contains (m) integers (b_1, b_2, \ldots, b_m) ((1 \le b_i \le 10^9)). It is also guaranteed that (b_i > b_{i+1}) for all (1 \le i < m). It is guaranteed that the sum of (\boldsymbol{n \cdot m}) over all test cases does not exceed (3 \cdot 10^5). For each test case, if it's possible to make (a) empty, then output the minimum total cost of the operations. If there is no possible sequence of operations which makes (a) empty, then output a single integ

Tutorials

Codeforces Round #982 (Div. 2) Editorial

Submissions

No solutions yet.