Joe, ever-efficient, has now turned to another form of green energy: solar power. Joe owns one solar panel which he will use to produce electricity each day.
Each day consists of
Joe's solar panel is an older model, and is rather hard to move. It requires
Joe would like to know the maximum total amount of energy he can collect, given that his solar panel may initially be at any position. Note that Joe cannot start moving the solar panel before sunrise.
Constraints
Input Specification
Input consists of two space-separated integers
Output Specification
Output on a single line the greatest amount of energy that Joe can collect on a single day.
Sample Input
10 6
Sample Output
87
Sun | Panel | Value |
---|---|---|
1 | 4 | 7 |
2 | 4 | 8 |
3 | 4 | 9 |
4 | 4 | 10 |
5 | 4 | 9 |
6 | 4 | 8 |
7 | 8 | 9 |
8 | 8 | 10 |
9 | 8 | 9 |
10 | 8 | 8 |
Comments