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 |
|---|---|---|---|---|---|---|
| 2147 | Codeforces Global Round 29 (Div. 1 + Div. 2) | FINISHED | False | 10800 | 18026723 | Sept. 20, 2025, 2:35 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 2106 ) | E | Maximum OR Popcount | PROGRAMMING | binary search bitmasks brute force data structures greedy |
You are given an array of (n) non-negative integers. You want to answer given (q) independent scenarios. In the (i)-th scenario, you are allowed to perform the following operation at most (b_i) times: Choose an element of the array and increase it by (1). Your goal is to maximize the number of bits that are equal to (1) in the bitwise OR of all numbers in the array. Find this number for each scenario. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^3)). The description of the test cases follows. The first line of each test case contains two integers (n) and (q) ((1 \leq n, q \leq 10^{5})) — the size of the array and the number of scenarios. The second line contains (n) integers (a_1, a_2, \ldots, a_n) ((0 \leq a_i \leq 10^{9})) — the elements of the array. The (i)-th of the next (q) lines contains a single integer (b_i) ((0 \leq b_i \leq 10^{9})) — the maximum number of operations allowed in the (i)-th scenario. It is guaranteed that the sum of (n) over all test cases does not exceed (10^{5}), and the sum of (q) over all test cases does not exceed (10^{5}). For each test case, output (q) lines, the (i)-th of them containing a single integer — the maximum possible number of bits equal to (1) in the bitwise OR in the (i)-th scenario. Visualizer link In the first test case: In the first scenario, we don't have any operations, and therefore the answer is equal to the number of (1)-bits in the bitwise OR of the original array, (0), which has (0) bits set in its binary representation. In the second scenario, one way of achieving (1) bit set in the bitwise OR is increasing (a_1) by (1) twice, obtaining a bitwise OR of (2={(10)}_2). It can be shown that it is the best possible value we can obtain by performing the operation at most twice. In the third scenario, one way |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 339645466 | cxf2006 | E | Sept. 21, 2025, 3:39 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 156 | 409600 | ||
| 339633739 | timg8710 | E | Sept. 20, 2025, 10:29 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 171 | 0 | ||
| 339592596 | forest | E | Sept. 20, 2025, 5:01 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 171 | 0 | ||
| 339620333 | lbssssssssssssss | E | Sept. 20, 2025, 7:46 p.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 171 | 102400 | ||
| 339594630 | Linear_B | E | Sept. 20, 2025, 5:07 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 171 | 409600 | ||
| 339644268 | qjm | E | Sept. 21, 2025, 3:17 a.m. | OK | C++17 (GCC 7-32) | TESTS | 20 | 186 | 1126400 | ||
| 339612900 | cjoa | E | Sept. 20, 2025, 6:52 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 187 | 0 | ||
| 339594567 | AlexanderL | E | Sept. 20, 2025, 5:07 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 187 | 0 | ||
| 339601597 | JurCai | E | Sept. 20, 2025, 5:28 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 202 | 2048000 | ||
| 339595762 | getawronganswer | E | Sept. 20, 2025, 5:10 p.m. | OK | C++17 (GCC 7-32) | TESTS | 19 | 202 | 2457600 | ||
| 339645060 | lucky_clover_ | E | Sept. 21, 2025, 3:31 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 124 | 512000 | ||
| 339637604 | www_bilibili_com | E | Sept. 21, 2025, 12:41 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 124 | 921600 | ||
| 339645170 | ss11111 | E | Sept. 21, 2025, 3:33 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 125 | 0 | ||
| 339639861 | Tobo | E | Sept. 21, 2025, 1:44 a.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 125 | 0 | ||
| 339600087 | gigachau | E | Sept. 20, 2025, 5:23 p.m. | OK | C++20 (GCC 13-64) | TESTS | 19 | 125 | 0 | ||
| 339617779 | darkvader3 | E | Sept. 20, 2025, 7:26 p.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 125 | 1638400 | ||
| 339634435 | whiitex | E | Sept. 20, 2025, 10:50 p.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 140 | 0 | ||
| 339634405 | whiitex | E | Sept. 20, 2025, 10:49 p.m. | OK | C++20 (GCC 13-64) | TESTS | 20 | 140 | 0 | ||
| 339590779 | flytime | E | Sept. 20, 2025, 4:55 p.m. | OK | C++20 (GCC 13-64) | TESTS | 19 | 140 | 0 | ||
| 339601833 | lddlinan | E | Sept. 20, 2025, 5:28 p.m. | OK | C++20 (GCC 13-64) | TESTS | 19 | 140 | 409600 | ||
| 339655817 | ChessRonak | E | Sept. 21, 2025, 5:57 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 124 | 0 | ||
| 339645869 | Ahmed_Elbana. | E | Sept. 21, 2025, 3:46 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 124 | 0 | ||
| 339650155 | Qzong | E | Sept. 21, 2025, 4:55 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 124 | 819200 | ||
| 339640910 | tin.le2 | E | Sept. 21, 2025, 2:07 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 125 | 0 | ||
| 339612117 | KIRIJIJI | E | Sept. 20, 2025, 6:47 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 19 | 125 | 1638400 | ||
| 339639020 | susvent | E | Sept. 21, 2025, 1:23 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 125 | 9523200 | ||
| 339656400 | aaditya.samadhiya11 | E | Sept. 21, 2025, 6:03 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 139 | 0 | ||
| 339651453 | AmiracleTa | E | Sept. 21, 2025, 5:11 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 139 | 0 | ||
| 339634102 | JustJie | E | Sept. 20, 2025, 10:40 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 20 | 140 | 0 | ||
| 339616369 | LennartF22 | E | Sept. 20, 2025, 7:15 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 19 | 140 | 0 | ||
| 339600817 | pengin_2000 | E | Sept. 20, 2025, 5:25 p.m. | OK | GNU C11 | TESTS | 19 | 765 | 1740800 | ||
| 339650269 | habibulka | E | Sept. 21, 2025, 4:57 a.m. | OK | Java 21 | TESTS | 20 | 437 | 921600 | ||
| 339636421 | wddd | E | Sept. 20, 2025, 11:58 p.m. | OK | Java 21 | TESTS | 20 | 514 | 819200 | ||
| 339639888 | godAngryOver | E | Sept. 21, 2025, 1:45 a.m. | OK | Java 21 | TESTS | 20 | 608 | 819200 | ||
| 339640491 | godAngryOver | E | Sept. 21, 2025, 1:58 a.m. | OK | Java 21 | TESTS | 20 | 608 | 2355200 | ||
| 339640261 | godAngryOver | E | Sept. 21, 2025, 1:53 a.m. | OK | Java 21 | TESTS | 20 | 640 | 1536000 | ||
| 339639783 | godAngryOver | E | Sept. 21, 2025, 1:43 a.m. | OK | Java 21 | TESTS | 20 | 858 | 1843200 | ||
| 339645364 | pierrot | E | Sept. 21, 2025, 3:37 a.m. | OK | PyPy 3-64 | TESTS | 20 | 390 | 17920000 | ||
| 339625656 | OpGm | E | Sept. 20, 2025, 8:35 p.m. | OK | PyPy 3-64 | TESTS | 20 | 405 | 28876800 | ||
| 339644844 | zouyu9631 | E | Sept. 21, 2025, 3:27 a.m. | OK | PyPy 3-64 | TESTS | 20 | 406 | 24166400 | ||
| 339645915 | young_skywalker_ | E | Sept. 21, 2025, 3:47 a.m. | OK | PyPy 3-64 | TESTS | 20 | 530 | 24268800 | ||
| 339593157 | CDastrup | E | Sept. 20, 2025, 5:02 p.m. | OK | PyPy 3-64 | TESTS | 19 | 686 | 48947200 | ||
| 339596238 | bronze_coder | E | Sept. 20, 2025, 5:11 p.m. | OK | PyPy 3-64 | TESTS | 19 | 890 | 83148800 | ||
| 339630754 | golomb | E | Sept. 20, 2025, 9:34 p.m. | OK | PyPy 3-64 | TESTS | 20 | 1171 | 12390400 | ||
| 339597287 | x3x3 | E | Sept. 20, 2025, 5:15 p.m. | OK | PyPy 3-64 | TESTS | 19 | 1296 | 43724800 | ||
| 339640973 | sansen | E | Sept. 21, 2025, 2:09 a.m. | OK | Rust 2021 | TESTS | 20 | 265 | 1638400 |
Back to search problems