CF797B.Odd sum

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given sequence a1,a2,...,ana_{1},a_{2},...,a_{n} of integer numbers of length nn . 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 nn ( 1<=n<=1051<=n<=10^{5} ).

The second line contains nn integer numbers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 104<=ai<=104-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
    

说明/提示

In the first example sum of the second and the fourth elements is 33 .

首页