Codeforces Round 1004 (Div. 1)

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
2066 Codeforces Round 1004 (Div. 1) FINISHED False 7200 37121123 Feb. 11, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 71 ) F Curse PROGRAMMING constructive algorithms dp math

You are given two arrays of integers: (a_1, a_2, \ldots, a_n) and (b_1, b_2, \ldots, b_m). You need to determine if it is possible to transform array (a) into array (b) using the following operation several (possibly, zero) times. Among all non-empty subarrays(^{\text{∗}}) of (a), choose any with the maximum sum, and replace this subarray with an arbitrary non-empty integer array. If it is possible, you need to construct any possible sequence of operations. Constraint: in your answer, the sum of the lengths of the arrays used as replacements must not exceed (n + m) across all operations. The numbers must not exceed (10^9) in absolute value. (^{\text{∗}})An array (a) is a subarray of an array (b) if (a) can be obtained from (b) by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 200)). The description of the test cases follows. The first line of each test case contains two integers (n, m) ((1 \le n, m \le 500)) — the lengths of arrays (a) and (b). The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((-10^6 \le a_i \le 10^6)) — the elements of array (a). The third line of each test case contains (m) integers (b_1, b_2, \ldots, b_m) ((-10^6 \le b_i \le 10^6)) — the elements of array (b). It is guaranteed that the sum of the values of (n) across all test cases does not exceed (500). It is guaranteed that the sum of the values of (m) across all test cases does not exceed (500). For each test case, output (-1) if it is impossible to transform array (a) into array (b). Otherwise, in the first line, output the number of operations (0 \leq q \leq n + m). Then output the operations in the following format in the

Tutorials

139415

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
305738860 A_G F Feb. 11, 2025, 11:23 p.m. OK C++20 (GCC 13-64) TESTS 138 156 102400
305716345 _DRVGON_ F Feb. 11, 2025, 6:39 p.m. OK C++20 (GCC 13-64) TESTS 138 202 2457600
305716113 _DRVGON_ F Feb. 11, 2025, 6:37 p.m. OK C++20 (GCC 13-64) TESTS 138 218 6144000
305717429 sevlll777 F Feb. 11, 2025, 6:48 p.m. OK C++20 (GCC 13-64) TESTS 138 233 5632000
305716229 _DRVGON_ F Feb. 11, 2025, 6:38 p.m. OK C++20 (GCC 13-64) TESTS 138 234 2457600
305711209 Radewoosh F Feb. 11, 2025, 6:04 p.m. OK C++20 (GCC 13-64) TESTS 138 343 2150400
305693016 rainboy F Feb. 11, 2025, 4:26 p.m. OK GNU C11 TESTS 138 405 6144000

remove filters

Back to search problems