Codeforces Round 1008 (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
2077 Codeforces Round 1008 (Div. 1) FINISHED False 9000 34787723 March 10, 2025, 2:45 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 258 ) F AND x OR PROGRAMMING bitmasks constructive algorithms dp

Suppose you have two arrays (c) and (d), each of length (k). The pair ((c, d)) is called good if (c) can be changed to (d) by performing the following operation any number of times. Select two distinct indices (i) and (j) ((1 \leq i, j \leq k), (i \neq j)) and a nonnegative integer (x) ((0 \leq x < 2^{30})). Then, apply the following transformations: (c_i := c_i \mathbin{\&} x), where (\&) denotes the bitwise AND operation . (c_j := c_j \mathbin{|} x), where (|) denotes the bitwise OR operation . (c_i := c_i \mathbin{\&} x), where (\&) denotes the bitwise AND operation . (c_j := c_j \mathbin{|} x), where (|) denotes the bitwise OR operation . You are given two arrays (a) and (b), both of length (n), containing nonnegative integers not exceeding (m). You can perform two types of moves on these arrays any number of times: Select an index (i) ((1 \leq i \leq n)) and set (a_i := a_i + 1). Select an index (i) ((1 \leq i \leq n)) and set (b_i := b_i + 1). Note that the elements of (a) and (b) may exceed (m) at some point while performing the moves. Find the minimum number of moves required to make the pair ((a, b)) good. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains two integers (n) and (m) ((1 \leq n, m \leq 2 \cdot 10^6)) — the length of arrays (a) and (b), and the maximum possible value in these arrays, respectively. The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \leq a_i \leq m)) — denoting the array (a). The third line contains (n) integers (b_1, b_2, \ldots, b_n) ((0 \leq b_i \leq m)) — denoting the array (b). Additionally, it is guaranteed that the sum of all values of (n) and the sum of a

Tutorials

Codeforces Round 1008 (Div. 1, Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
309872101 ay1357 F March 10, 2025, 7 p.m. OK C++17 (GCC 7-32) TESTS 53 984 37580800
309902010 cdxcdxcdxcdx F March 11, 2025, 1:51 a.m. OK C++17 (GCC 7-32) TESTS 53 1125 170803200
309903527 cdxcdxcdxcdx F March 11, 2025, 2:19 a.m. OK C++17 (GCC 7-32) TESTS 53 1140 170803200
309848336 alireza_kaviani F March 10, 2025, 4:44 p.m. OK C++17 (GCC 7-32) TESTS 53 1327 53145600
309901132 jiangbowen F March 11, 2025, 1:36 a.m. OK C++17 (GCC 7-32) TESTS 53 1499 154726400
309857022 potato167 F March 10, 2025, 5:07 p.m. OK C++17 (GCC 7-32) TESTS 53 1578 146534400
309900824 Sparkle_Twilight F March 11, 2025, 1:30 a.m. OK C++17 (GCC 7-32) TESTS 53 2030 154726400
309899282 jiangbowen F March 11, 2025, 1:05 a.m. OK C++17 (GCC 7-32) TESTS 53 2031 154726400
309903434 cdxcdxcdxcdx F March 11, 2025, 2:18 a.m. OK C++17 (GCC 7-32) TESTS 53 4593 170803200
309901840 cdxcdxcdxcdx F March 11, 2025, 1:48 a.m. OK C++17 (GCC 7-32) TESTS 53 4593 170803200
309913925 qiuzx F March 11, 2025, 4:51 a.m. OK C++20 (GCC 13-64) TESTS 53 421 37683200
309836201 tourist F March 10, 2025, 4:14 p.m. OK C++20 (GCC 13-64) TESTS 53 718 12083200
309848959 Ormlis F March 10, 2025, 4:46 p.m. OK C++20 (GCC 13-64) TESTS 53 765 12083200
309901695 romegenixxx F March 11, 2025, 1:46 a.m. OK C++20 (GCC 13-64) TESTS 53 858 20480000
309870820 jtnydv25 F March 10, 2025, 6:49 p.m. OK C++20 (GCC 13-64) TESTS 53 874 37888000
309903334 cdxcdxcdxcdx F March 11, 2025, 2:16 a.m. OK C++20 (GCC 13-64) TESTS 53 952 170598400
309902322 cdxcdxcdxcdx F March 11, 2025, 1:57 a.m. OK C++20 (GCC 13-64) TESTS 53 953 170598400
309905900 dog_of_Nesraychan F March 11, 2025, 2:58 a.m. OK C++20 (GCC 13-64) TESTS 53 983 148377600
309865017 kotatsugame F March 10, 2025, 6:04 p.m. OK C++20 (GCC 13-64) TESTS 53 1062 88166400
309865507 BurnedChicken F March 10, 2025, 6:07 p.m. OK C++20 (GCC 13-64) TESTS 53 1249 45772800
309847464 Golovanov399 F March 10, 2025, 4:42 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 655 32563200
309920332 yuto1115 F March 11, 2025, 5:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 53 702 31334400
309885298 Noam527 F March 10, 2025, 9:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 733 12492800
309823042 jiangly F March 10, 2025, 3:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 874 49459200
309888103 Halzion F March 10, 2025, 9:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 937 28979200
309895253 tfg F March 10, 2025, 11:48 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 1031 146636800
309854764 Endagorion F March 10, 2025, 5:01 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 1093 95436800
309894746 Mangooste F March 10, 2025, 11:37 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 1218 79462400
309848201 244mhq F March 10, 2025, 4:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 1281 95846400
309847924 Kevin114514 F March 10, 2025, 4:43 p.m. OK C++23 (GCC 14-64, msys2) TESTS 53 1811 74649600
309841926 rainboy F March 10, 2025, 4:27 p.m. OK GNU C11 TESTS 53 702 66560000
309843640 conqueror_of_tourist F March 10, 2025, 4:32 p.m. OK PyPy 3-64 TESTS 53 2109 231424000

remove filters

Back to search problems