22 template<std::
integral T>
27 std::vector<T> prefixMax(v.size());
29 for (
size_t i = 1; i < v.size(); ++i) {
30 prefixMax[i] = std::max(prefixMax[i - 1], v[i]);
46 template<std::
integral T>
51 std::vector<T> suffixMax(v.size());
53 suffixMax[n - 1] = v[n - 1];
54 for (
size_t i = n - 2; i < n; --i) {
55 suffixMax[i] = std::max(suffixMax[i + 1], v[i]);
71 template<std::
integral T>
76 std::vector<T> prefixMin(v.size());
78 for (
size_t i = 1; i < v.size(); ++i) {
79 prefixMin[i] = std::min(prefixMin[i - 1], v[i]);
95 template<std::
integral T>
100 std::vector<T> suffixMin(v.size());
102 suffixMin[n - 1] = v[n - 1];
103 for (
size_t i = n - 2; i < n; --i) {
104 suffixMin[i] = std::min(suffixMin[i + 1], v[i]);
120 template<std::
integral T>
125 std::vector<T> prefixSum(v.size());
126 std::partial_sum(v.begin(), v.end(), prefixSum.begin());
141 template<std::
integral T>
146 std::vector<T> suffixSum(v.size());
148 std::partial_sum(v.rbegin(), v.rend(), suffixSum.rbegin());
Definition big_integer.hpp:14
static std::vector< T > getSuffixSum(const std::vector< T > &v)
Computes the suffix sums of a given vector.
Definition prefix_suffix.hpp:142
static std::vector< T > getSuffixMin(const std::vector< T > &v)
Computes the suffix minimums of a given vector.
Definition prefix_suffix.hpp:96
static std::vector< T > getSuffixMax(const std::vector< T > &v)
Computes the suffix maximums of a given vector.
Definition prefix_suffix.hpp:47
static std::vector< T > getPrefixMin(const std::vector< T > &v)
Computes the prefix minimums of a given vector.
Definition prefix_suffix.hpp:72
static std::vector< T > getPrefixMax(const std::vector< T > &v)
Computes the prefix maximums of a given vector.
Definition prefix_suffix.hpp:23
static std::vector< T > getPrefixSum(const std::vector< T > &v)
Computes the prefix sums of a given vector.
Definition prefix_suffix.hpp:121