## Solar Power

View as PDF

Points: 5
Time limit: 0.1s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 minutes, over each of which the Sun changes position from sunrise at position to sunset at position . The energy collected by the solar panel depends on the distance between its own position and the Sun's position. Formally, if the solar panel is at a position and the Sun is at a position , the energy collected during that minute is .

Joe's solar panel is an older model, and is rather hard to move. It requires minutes to move it to a new location, during which time it is still collecting power from its current position.

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.

#### Input Format

Input consists of two space-separated integers and on a single line.

#### Output Format

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