oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

summation Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

summation.html

Problem Description

Rar the cat has a list of N numbers in the range of -10000 to 10000. He wants to know the maximum sum obtainable by either subtracting or adding the numbers. The sum starts with 0 and you can either subtract or add a particular number in the list only once to the sum.

Input

The first line will consist of a single integer, N.

The second line will consist of N integers, in the range of -10000 to 10000.

Output

A single integer, the maximum sum obtainable by either subtracting or adding each number to one another.

Limits

Subtask 1 (100%): 0 < N ≤ 100000

Subtask 2 (0%): As per sample testcases.

Sample Testcase 1

Input:

5
1 -2 -3 4 5

Output:

15

Explanation:
By adding 1, 4, 5 to the sum and subtracting -2 and -3 from the sum, the maximum of 15 is obtained.

Sample Testcase 2

Input:

5
-1 -2 -3 -4 -5

Output:

15

Explanation:
By subtracting -1, -2, -3, -4 and -5 from the sum, the maximum of 15 is obtained.

Tags

Raffles Cat Helping Practice Contest 2013, Syntax

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100201s64MBMinimum
2021s64MBMinimum

Judge Compile Command

g++-8 ans.cpp -o summation -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.