304161: CF797B. Odd sum
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Odd sum
题意翻译
### 题目描述: 现给予你一个长度为n,包含正整数的序列 ***a1,a2……an***,你的任务是找到一个和为奇数且值最大(在和为奇数的子序列中)的子序列。可以保证该序列中有和为奇数的子序列 子序列是一个可以通过删除一个序列中的部分元素,但不改变其他元素的顺序后得到的新序列 现在请你写一个程序找到上述的这样一个子序列 ### 输入格式: 第一行包含一个整数***(1<=n<=10^5)*** 第二行包含n个整数***a1,a2……an(-10^4<=ai<=10^4)*** 该序列包含至少一个和为奇数的子序列 ### 输出格式: 输出找到的子序列的和 ### 说明: 第一个样例中的第二个元素与第四个元素的和为3题目描述
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. Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. You should write a program which finds sum of the best subsequence.输入输出格式
输入格式
The first line contains integer number $ n $ ( $ 1<=n<=10^{5} $ ). The second line contains $ n $ integer numbers $ a_{1},a_{2},...,a_{n} $ ( $ -10^{4}<=a_{i}<=10^{4} $ ). The sequence contains at least one subsequence with odd sum.
输出格式
Print sum of resulting subseqeuence.
输入输出样例
输入样例 #1
4
-2 2 -3 1
输出样例 #1
3
输入样例 #2
3
2 -5 -3
输出样例 #2
-1