Problem p02602 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, n, m) for (int i = (m), i##_len = (n); i < i##_len; ++i)
#define EACH(i, v) for (const auto &i : v)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Value> using vec = vector<Value>;
using ll = long long;
using P = pair<long long, long long>;
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "Yes";
const string NO = "No";

void Main();
void solve(long long N, long long K, std::vector<long long> A);

int main() {
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

void Main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
}

void solve(long long N, long long K, std::vector<long long> A) {
  FOR(i, N - K, 0) {
    if (A[i] < A[i + K]) {
      cout << YES << el;
    } else {
      cout << NO << el;
    }
  }
}


Error: TLE

Fixed submission:

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, n, m) for (int i = (m), i##_len = (n); i < i##_len; ++i)
#define EACH(i, v) for (const auto &i : v)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Value> using vec = vector<Value>;
using ll = long long;
using P = pair<long long, long long>;
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "Yes";
const string NO = "No";

void Main();
void solve(long long N, long long K, std::vector<long long> A);

int main() {
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

void Main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, K, std::move(A));
}

void solve(long long N, long long K, std::vector<long long> A) {
  vec<cpp_int> score(N, 1);
  REP(i, K) { score[0] *= A[i]; }
  FOR(i, N - K + 1, 1) {
    score[i] = score[i - 1] / A[i - 1];
    score[i] *= A[i + K - 1];
  }
  FOR(i, N - K + 1, 1) {
    if (score[i - 1] < score[i]) {
      cout << YES << el;
    } else {
      cout << NO << el;
    }
  }
}