{"problem":{"name":"B. Odd sum","description":{"content":"You are given sequence _a_1, _a_2, ..., _a__n_ of integer numbers of length _n_. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF797B"},"statements":[{"statement_type":"Markdown","content":"You are given sequence _a_1, _a_2, ..., _a__n_ of integer numbers of length _n_. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum.\n\nSubsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.\n\nYou should write a program which finds sum of the best subsequence.\n\n## Input\n\nThe first line contains integer number _n_ (1 ≤ _n_ ≤ 105).\n\nThe second line contains _n_ integer numbers _a_1, _a_2, ..., _a__n_ ( - 104 ≤ _a__i_ ≤ 104). The sequence contains at least one subsequence with odd sum.\n\n## Output\n\nPrint sum of resulting subseqeuence.\n\n[samples]\n\n## Note\n\nIn the first example sum of the second and the fourth elements is 3.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"给定一个长度为 #cf_span[n] 的整数序列 #cf_span[a1, a2, ..., an]。你的任务是找到一个子序列，使得其交错和为奇数，并且在所有满足此条件的子序列中最大。题目保证给定序列中至少存在一个交错和为奇数的子序列。\n\n子序列是指通过删除原序列中的一些元素（不改变剩余元素的顺序）而得到的序列。\n\n你需要编写一个程序，找出最优子序列的和。\n\n第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 105])。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an] (#cf_span[ - 104 ≤ ai ≤ 104])。序列中至少包含一个交错和为奇数的子序列。\n\n请输出所求子序列的和。\n\n在第一个例子中，第二个和第四个元素的和为 #cf_span[3]。\n\n## Input\n\n第一行包含整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 105])。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an] (#cf_span[ - 104 ≤ ai ≤ 104])。序列中至少包含一个交错和为奇数的子序列。\n\n## Output\n\n请输出所求子序列的和。\n\n[samples]\n\n## Note\n\n在第一个例子中，第二个和第四个元素的和为 #cf_span[3]。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ denote the length of the sequence.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers, where $ a_i \\in \\mathbb{Z} $ and $ -10^4 \\leq a_i \\leq 10^4 $.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. The sequence $ A $ contains at least one subsequence with odd sum.  \n\n**Objective**  \nFind the maximum sum $ S $ among all subsequences of $ A $ such that $ S $ is odd:  \n$$\nS = \\max \\left\\{ \\sum_{i \\in I} a_i \\,\\middle|\\, I \\subseteq \\{1, 2, \\dots, n\\},\\ \\sum_{i \\in I} a_i \\text{ is odd} \\right\\}\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF797B","tags":["dp","greedy","implementation"],"sample_group":[["4\n-2 2 -3 1","3"],["3\n2 -5 -3","\\-1"]],"created_at":"2026-03-03 11:00:39"}}