September 2021 cohort is finalized with 45 amazing folks. For future cohorts

# CHRL4 Solution

``````/*
*  Author: Arpit Bhayani
*  https://arpitbhayani.me
*/
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <deque>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

#define ll long long

#define MIN(a, b) a < b ? a : b

using namespace std;
int val;
priority_queue<pair<double, int> > pq;
double temp;
// Used to store logs because we need to determine the order even
// when multiplication is "mod" within bounded range

int main(int argc, char *argv[]) {
int n, k;
scanf("%d%d", &n, &k);
for ( int i = 0 ; i < n ; i++ ) {
scanf("%d", &val[i]);
}

temp = log(val);

pq.push(make_pair(-temp, 0)); // negative because we want smallest value

for (int i = 1 ; i < n ; i++) {
while (i - pq.top().second > k) {
pq.pop();
}
temp[i] = log(val[i]) + temp[pq.top().second];
pq.push(make_pair(-temp[i], i));
}

return 0;
}
``````