#K41522. Maximum Seats Allocation

    ID: 26884 Type: Default 1000ms 256MiB

Maximum Seats Allocation

Maximum Seats Allocation

You are given n tables and a maximum allowed distance d between any two consecutive tables. Each table can accommodate a fixed number of seats, given in a list. Although the parameter d may suggest a spatial restriction between consecutive tables, in this problem the tables can always be arranged within the allowed distance. Thus, the maximum number of seats that can be utilized is simply the sum of the seats available at each table.

Input Format: The first line contains two integers n and d separated by a space. The second line contains n space-separated integers indicating the number of seats available at each table.

Output Format: Output a single integer representing the total number of seats.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains two integers: n – the number of tables, and d – the maximum allowed distance between consecutive tables.
  • The second line contains n space-separated integers. Each integer indicates the number of seats available at each table.

outputFormat

Print a single integer to standard output (stdout) which is the sum of the available seats.

## sample
5 10
3 5 8 2 6
24