0% found this document useful (0 votes)
25 views2 pages

Destruction of Dandelion Fields

Uploaded by

modakbutterfly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Destruction of Dandelion Fields

Uploaded by

modakbutterfly
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

9/13/25, 10:00 PM Problem - D - Codeforces

|
IC_Br0ken | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN

Please subscribe to the official Codeforces channel in Telegram via the link [Link] ×

PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS STANDINGS CUSTOM INVOCATION

Codeforces Round 1050 (Div. 4)


D. Destruction of the Dandelion Fields Contest is running
time limit per test: 2 seconds
00:19:05
memory limit per test: 256 megabytes
Contestant
Farmer John has a lawnmower, initially turned off. He also has n fields, with the i -th field having ai dandelions. He
will visit all the fields in any order he wants, and each field exactly once.

FJ's lawnmower seems to have a mind of its own. Right before visiting a field, it checks if the field has an even or
odd number of dandelions. If it has an odd number, then the lawnmower toggles its state (if it is off, it turns on; if it is → Submit?
on, it turns off). Then, if the lawnmower is on, it will cut all dandelions in that field. Otherwise, if the lawnmower is off,
then FJ will simply visit the field and cut no dandelions. Language: PyPy 3.10 (7.3.15, 64bit)

If FJ visits the n fields in optimal order, what is the maximum total number of dandelions he can cut? Choose
Choose File No file chosen
file:

Input Submit
The first line contains an integer t (1
4
≤ t ≤ 10 ) — the number of test cases.

The first line contains an integer n (1


5
≤ n ≤ 2 ⋅ 10 ) — the number of fields.
→ Last submissions
9
The following line contains n space-separated integers a1 , a2 , … , an (1 ≤ ai ≤ 10 ) — the number of Submission Time Verdict
dandelions in each field. Sep/13/2025 Runtime error on
338496769
19:29 test 1
5
It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10 .

Output
[Link] 1/2
9/13/25, 10:00 PM Problem - D - Codeforces

For each test case, output an integer on a new line: maximum dandelions FJ can cut if he visits all n fields in
optimal order.

Example
input Copy

3
3
2 4 6
4
4 2 1 6
4
1000000000 999999999 1000000000 999999999

output Copy

0
13
2999999999

Note
For the first test case, since there is no field with an odd number of dandelions, FJ can never turn his lawnmower
on. Since his lawnmower is always off, he can never cut any dandelions, so the answer is 0.

For the second test case, FJ can visit the third field first; then his lawnmower will turn on. Then he can visit the other
fields in any order. Since his lawnmower is always on, dandelions in every field can be cut.

For the third test case, FJ can visit the fields in the following order: field 2, field 1, field 3, then field 4.

Codeforces (c) Copyright 2010-2025 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Sep/13/2025 22:00:52UTC+5.5 (f1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions

Supported by

[Link] 2/2

You might also like