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

//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REC(f, ...)                                                            \\
  (void)0;                                                                     \\
  const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template <typename T> class in {
  T value;

public:
  in() { cin >> value; }
  operator const T &() const { return value; }
  operator T &() { return value; }
  in &operator=(T source) {
    value = source;
    return *this;
  }
};
template <> class in<string> : public string {
public:
  in() { cin >> *this; }
};
template <class T> class inseq : public T {
public:
  template <typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) {
    for (auto &&i : *this)
      cin >> i;
  }
};
template <class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, K;
  invec<ll> A(N);

  long double now = 1, prev;

  REP(i, K)
  now += A[i];

  prev = now;
  for (int i = K; i < N; i++) {
    now = now - A[i - K] + A[i];
    cout << (now > prev ? "Yes" : "No") << endl;
    prev = now;
  }
}

template <typename T> void plot(const T &func) {
  cout << setprecision(9) << func() << endl;
}
template <> void plot<void()>(void (&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}


Error: TLE

Fixed submission:

//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REC(f, ...)                                                            \\
  (void)0;                                                                     \\
  const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
namespace icl = boost::icl;
template <typename T> class in {
  T value;

public:
  in() { cin >> value; }
  operator const T &() const { return value; }
  operator T &() { return value; }
  in &operator=(T source) {
    value = source;
    return *this;
  }
};
template <> class in<string> : public string {
public:
  in() { cin >> *this; }
};
template <class T> class inseq : public T {
public:
  template <typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) {
    for (auto &&i : *this)
      cin >> i;
  }
};
template <class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N, K;
  invec<ll> A(N);

  bst::multiprecision::cpp_int now = 1, prev;

  REP(i, K)
  now *= A[i];

  prev = now;
  for (int i = K; i < N; i++) {
    now = now * A[i] / A[i - K];
    cout << (now > prev ? "Yes" : "No") << endl;
    prev = now;
  }
}

template <typename T> void plot(const T &func) {
  cout << setprecision(9) << func() << endl;
}
template <> void plot<void()>(void (&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}