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 |
---|---|---|---|---|---|---|
1688 | Codeforces Round 796 (Div. 2) | FINISHED | False | 7200 | 82999463 | June 3, 2022, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 18422 ) | B | Patchouli's Magical Talisman | PROGRAMMING | bitmasks constructive algorithms greedy sortings |
B'Patchouli is making a magical talisman. She initially has n magical tokens. Their magical power can be represented with positive integers a_1, a_2, ldots, a_n . Patchouli may perform the following two operations on the tokens. Tokens are more effective when their magical powers are odd values. Please help Patchouli to find the minimum number of operations she needs to make magical powers of all tokens odd values. Each test contains multiple test cases. The first line contains a single integer t ( 1 <= q t <= q 10^3 ) -- the number of test cases. The description of the test cases follows. For each test case, the first line contains one integer n ( 1 <= q n <= q 2 cdot 10^5 ) -- the initial number of tokens. The second line contains n intergers a_1,a_2, ldots,a_n ( 1 <= q a_i <= q 10^9 ) -- the initial magical power of the n tokens. It is guaranteed that the sum of n over all test cases does not exceed 2 cdot 10^5 . For each test case, print a single integer -- the minimum number of operations Patchouli needs to make all tokens have an odd value of magical power. It can be shown that under such restrictions the required sequence of operations exists. Test case 1: a consists solely of odd numbers initially. Test case 2: Choose the tokens with magical power of 1 and 2 and perform Fusion. Now a=[1,3] , both are odd numbers. Test case 3: Choose the tokens with magical power of 2 and 8 and perform Fusion. Now a=[4,10] . Choose the token with magical power of 10 and perform Reduction. Now a=[4,5] . Choose the tokens with magical power of 4 and 5 and perform Fusion. Now a=[9] , and 9 is an odd number. It can be shown that you can not make all the magical powers odd numbers in less than 3 moves, so the answer is 3 . '... |
Tutorial |
No solutions yet.