Submit | All submissions | Best solutions | Back to list |
EICELGAME - Cell game |
Given a row of N cells, numbered from 1 to N. Each cell contain a given value. If a cell containing the value of V is selected, you will earn V points, otherwise, you will earn 2*V points. Note that for every two adjacent cells, you must select at least one of them. Calculate the maximum point you can earn.
Input
- The first line contains one integer N - the number of cells (1 £ N £ 105).
- The next line contains N integers which are values of N cells, respectively.
- All integers don’t exceed 109.
Output
The maximum point.
Sample
Input |
Output |
5 4 3 -5 6 8 |
28 |
Added by: | Ha Minh Ngoc |
Date: | 2023-04-02 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |