Number removal puzzle
Submit solution
Points:
2 (partial)
Time limit:
1.0s
Memory limit:
67M
Author:
Problem type
Allowed languages
Ada, Assembly, Awk, C, C++, C11, CLANG, CLANGX, Classical, COBOL, Coffee, CSC, D lang, DART, F95, FORTH, Fortrn, GAS32, GO, Haskell, Itercal, Java, kotlin, LEAN, LISP, LUA, MONOVB, Nasm, OCAML, Pascal, Perl, php, PIKE, prolog, Pypy, Python, Ruby 2, RUST, Scala, SCM, SED, SWIFT, TCL, TUR, V8JS, VB, ZIG
Dorian challenges Koi with a puzzle, called "Number removal": Koi is given an array of
To prevent Koi gets the smallest sum by removing all positive numbers, Dorian adds another constraint: two consecutive elements can't be erased.
Fellow coders, please help Koi solve this puzzle.
Input
The first line of the input contains integer
The second line contains
Output
A single integer - the answer to Dorian's puzzle.
Example
Input 1:
Copy
10
1 2 3 4 5 6 7 8 9 10
Output 1:
Copy
25
Explaination: Koi removes all even integers from
Input 2:
Copy
5
1 -6 5 9 -8
Output 2:
Copy
-9
Explaination: Koi removes
Comments