Codeforces Round 1020 (Div. 3)

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
2106 Codeforces Round 1020 (Div. 3) FINISHED False 8100 30900323 April 24, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 12196 ) D Flower Boy PROGRAMMING binary search dp greedy two pointers

Flower boy has a garden of (n) flowers that can be represented as an integer sequence (a_1, a_2, \dots, a_n), where (a_i) is the beauty of the (i)-th flower from the left. Igor wants to collect exactly (m) flowers. To do so, he will walk the garden from left to right and choose whether to collect the flower at his current position. The (i)-th flower among ones he collects must have a beauty of at least (b_i). Igor noticed that it might be impossible to collect (m) flowers that satisfy his beauty requirements, so before he starts collecting flowers, he can pick any integer (k) and use his magic wand to grow a new flower with beauty (k) and place it anywhere in the garden (between two flowers, before the first flower, or after the last flower). Because his magic abilities are limited, he may do this at most once . Output the minimum integer (k) Igor must pick when he performs the aforementioned operation to ensure that he can collect (m) flowers. If he can collect (m) flowers without using the operation, output (0). If it is impossible to collect (m) flowers despite using the operation, output (-1). The first line of the input contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains exactly two integers (n) and (m) ((1 \le m \le n \le 2 \cdot 10^5)) — the number of flowers in the garden and the number of flowers Igor wants to collect, respectively. The second line of each test case contains (n) integers (a_1, a_2, ..., a_n) ((1 \le a_i \le 10^9)) — where (a_i) is the beauty of the (i)-th flower from the left in the garden. The third line of each test case contains (m) integers (b_1, b_2, ..., b_m) ((1 \le b_i \le 10^9)) — where (b_i) is the minimum beauty the (i)-th flower must have that Igor will collect. It is guaranteed that the sum of (n) over all test cases does no

Tutorials

Codeforces Round 1020 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
317077147 chrisTris D April 24, 2025, 4:49 p.m. OK C# 10 TESTS 9 171 38502400
317074030 SMMaster D April 24, 2025, 4:43 p.m. OK C# 10 TESTS 9 187 45772800
317081155 GG_Grass D April 24, 2025, 5:07 p.m. OK C++17 (GCC 7-32) TESTS 9 109 0
317104353 razon_hasssan D April 24, 2025, 8:44 p.m. OK C++17 (GCC 7-32) TESTS 9 109 102400
317131928 i-am-vivek D April 25, 2025, 5:27 a.m. OK C++17 (GCC 7-32) TESTS 9 109 3276800
317082957 pgergo03 D April 24, 2025, 5:19 p.m. OK C++17 (GCC 7-32) TESTS 9 109 3276800
317123599 AhmedIbrahim30 D April 25, 2025, 3:14 a.m. OK C++17 (GCC 7-32) TESTS 9 109 16179200
317129710 ryu_eclipse D April 25, 2025, 5 a.m. OK C++17 (GCC 7-32) TESTS 9 124 0
317127401 DiegoIvan D April 25, 2025, 4:23 a.m. OK C++17 (GCC 7-32) TESTS 9 124 0
317127383 diegoivan.10290 D April 25, 2025, 4:23 a.m. OK C++17 (GCC 7-32) TESTS 9 124 0
317126136 C_Top D April 25, 2025, 4:02 a.m. OK C++17 (GCC 7-32) TESTS 9 124 0
317109847 yash089 D April 24, 2025, 10:08 p.m. OK C++17 (GCC 7-32) TESTS 9 124 0

remove filters

Back to search problems