PROBLEM LINK:
Author, Tester and Editorialist: Jitin
DIFFICULTY:
EASY
EXPLANATION:
Consider the case when the i_{th} contestant competes with the $i-1$th contestant:
\bullet The score of the i_{th} contestant is given as A_iA_i+1...A_{i+k-2}A_{i+k-1}
\bullet The score of the i-1_{th} contestant is given as A_{i-1}A_i...A_{i+k-3}A_{i+k-2}
On Careful Observation we can notice that the product of A_iA_{i+1}...A_{i+k-2} is common in both the products. So we can directly compare the elements A_{i-1} and A_{i+k-1} to determine whether the i_{th} contestant will win or not.
SOLUTIONS:
C++ Solution
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, k;
cin >> n >> k;
int a[n + 1];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
for (int i = k; i < n; i++)
{
if (a[i] > a[i - k])
{
cout << "Yes\n";
}
else
{
cout << "No\n";
}
}
return 0;
}