Limits: 3s, 512 MB
After huge success in Borhani business, Biswa has recently started restaurant business. He’s got the information about the numbers of customers for N days, a sequence of N integers a1, a2, …, aN. He wants to calculate the popularity of his restaurant from this data. First he’ll choose a window of size K (≤ N). Then for each K-sized window from the original sequence (first K-sized window will contain a1, a2, …, aK, second one will contain a2, a3, …, aK+1, and so on), he’ll calculate the number of all possible continuous increasing sequences in it and write them down in order. It’ll create a sequence of N - K + 1 integers b1, b2, …, bN-K+1. Finally he’ll run the following function on the later found sequence: Output of this function is the popularity that Biswa desires to calculate.
This is a companion discussion topic for the original entry at https://toph.co/p/biswa-and-restaurant-business