#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef KK2_TEMPLATE_PROCON_HPP #define KK2_TEMPLATE_PROCON_HPP 1 #ifndef KK2_TEMPLATE_CONSTANT_HPP #define KK2_TEMPLATE_CONSTANT_HPP 1 #ifndef KK2_TEMPLATE_TYPE_ALIAS_HPP #define KK2_TEMPLATE_TYPE_ALIAS_HPP 1 using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128_t; using u128 = __uint128_t; using pi = std::pair; using pl = std::pair; using pil = std::pair; using pli = std::pair; template using vc = std::vector; template using vvc = std::vector>; template using vvvc = std::vector>; template using vvvvc = std::vector>; template using pq = std::priority_queue; template using pqi = std::priority_queue, std::greater>; #endif // KK2_TEMPLATE_TYPE_ALIAS_HPP template constexpr T infty = 0; template <> constexpr int infty = (1 << 30) - 123; template <> constexpr i64 infty = (1ll << 62) - (1ll << 31); template <> constexpr i128 infty = (i128(1) << 126) - (i128(1) << 63); template <> constexpr u32 infty = infty; template <> constexpr u64 infty = infty; template <> constexpr u128 infty = infty; template <> constexpr double infty = infty; template <> constexpr long double infty = infty; constexpr int mod = 998244353; constexpr int modu = 1e9 + 7; constexpr long double PI = 3.14159265358979323846; #endif // KK2_TEMPLATE_CONSTANT_HPP #ifndef KK2_TEMPLATE_FUNCTION_UTIL_HPP #define KK2_TEMPLATE_FUNCTION_UTIL_HPP 1 #ifndef KK2_MATH_MONOID_MAX_HPP #define KK2_MATH_MONOID_MAX_HPP 1 #ifndef KK2_TYPE_TRAITS_IO_HPP #define KK2_TYPE_TRAITS_IO_HPP 1 namespace kk2 { namespace type_traits { struct istream_tag {}; struct ostream_tag {}; } // namespace type_traits template using is_standard_istream = typename std::conditional::value || std::is_same::value, std::true_type, std::false_type>::type; template using is_standard_ostream = typename std::conditional::value || std::is_same::value, std::true_type, std::false_type>::type; template using is_user_defined_istream = std::is_base_of; template using is_user_defined_ostream = std::is_base_of; template using is_istream = typename std::conditional::value || is_user_defined_istream::value, std::true_type, std::false_type>::type; template using is_ostream = typename std::conditional::value || is_user_defined_ostream::value, std::true_type, std::false_type>::type; template using is_istream_t = std::enable_if_t::value>; template using is_ostream_t = std::enable_if_t::value>; } // namespace kk2 #endif // KK2_TYPE_TRAITS_IO_HPP namespace kk2 { namespace monoid { template > struct Max { static constexpr bool commutative = true; using M = Max; S a; bool is_unit; Max() : a(S()), is_unit(true) {} Max(S a_) : a(a_), is_unit(false) {} operator S() const { return a; } inline static M op(M l, M r) { if (l.is_unit or r.is_unit) return l.is_unit ? r : l; return Compare{}(l.a, r.a) ? r : l; } inline static M unit() { return M(); } bool operator==(const M &rhs) const { return is_unit == rhs.is_unit and (is_unit or a == rhs.a); } bool operator!=(const M &rhs) const { return is_unit != rhs.is_unit or (!is_unit and a != rhs.a); } template * = nullptr> friend OStream &operator<<(OStream &os, const M &x) { if (x.is_unit) os << "-inf"; else os << x.a; return os; } template * = nullptr> friend IStream &operator>>(IStream &is, M &x) { is >> x.a; x.is_unit = false; return is; } }; } // namespace monoid } // namespace kk2 #endif // MATH_MONOID_MAX_HPP #ifndef KK2_MATH_MONOID_MIN_HPP #define KK2_MATH_MONOID_MIN_HPP 1 namespace kk2 { namespace monoid { template > struct Min { static constexpr bool commutative = true; using M = Min; S a; bool is_unit; Min() : a(S()), is_unit(true) {} Min(S a_) : a(a_), is_unit(false) {} operator S() const { return a; } inline static M op(M l, M r) { if (l.is_unit or r.is_unit) return l.is_unit ? r : l; return Compare{}(l.a, r.a) ? l : r; } inline static M unit() { return M(); } bool operator==(const M &rhs) const { return is_unit == rhs.is_unit and (is_unit or a == rhs.a); } bool operator!=(const M &rhs) const { return is_unit != rhs.is_unit or (!is_unit and a != rhs.a); } template * = nullptr> friend OStream &operator<<(OStream &os, const M &x) { if (x.is_unit) os << "inf"; else os << x.a; return os; } template * = nullptr> friend IStream &operator>>(IStream &is, M &x) { is >> x.a; x.is_unit = false; return is; } }; } // namespace monoid } // namespace kk2 #endif // KK2_MATH_MONOID_MIN_HPP #ifndef KK2_TYPE_TRAITS_CONTAINER_TRAITS_HPP #define KK2_TYPE_TRAITS_CONTAINER_TRAITS_HPP 1 namespace kk2 { template struct is_vector : std::false_type {}; template struct is_vector> : std::true_type {}; // コンテナかどうかを判定するtraits template struct is_container : std::false_type {}; // 基本的なコンテナ型の特殊化 template struct is_container> : std::true_type { }; template struct is_container> : std::true_type {}; template struct is_container> : std::true_type {}; template struct is_container> : std::true_type {}; template struct is_container> : std::true_type {}; // SFINAEでコンテナを判定するためのヘルパー template using is_container_t = typename std::enable_if_t::value, std::nullptr_t>; } // namespace kk2 #endif // KK2_TYPE_TRAITS_CONTAINER_TRAITS_HPP namespace kk2 { template auto make_vector(int first, Sizes... sizes) { if constexpr (sizeof...(sizes) == 0) { return std::vector(first); } else { return std::vector(sizes...))>(first, make_vector(sizes...)); } } template void fill_all(std::vector &v, const U &x) { if constexpr (is_vector::value) { for (auto &u : v) fill_all(u, x); } else { std::fill(v.begin(), v.end(), T(x)); } } template int iota_all(std::vector &v, U x, int offset = 0) { if constexpr (is_vector::value) { for (auto &u : v) offset += iota_all(u, x + offset); } else { for (auto &u : v) u = x++, ++offset; } return offset; } template int mysize(const C &c) { return size(c); } // T: commutative monoid, F: (U, T) -> U template U all_monoid_prod(const std::vector &v, U unit, const F &f) { U res = unit; if constexpr (is_vector::value) { for (const auto &x : v) res = f(res, all_monoid_prod(x, unit, f)); } else { for (const auto &x : v) res = f(res, x); } return res; } template U all_sum(const std::vector &v, U unit = U()) { return all_monoid_prod(v, unit, [](U a, U b) { return a + b; }); } template U all_prod(const std::vector &v, U unit = U(1)) { return all_monoid_prod(v, unit, [](U a, U b) { return a * b; }); } template U all_xor(const std::vector &v, U unit = U()) { return all_monoid_prod(v, unit, [](U a, U b) { return a ^ b; }); } template U all_and(const std::vector &v, U unit = U(-1)) { return all_monoid_prod(v, unit, [](U a, U b) { return a & b; }); } template U all_or(const std::vector &v, U unit = U()) { return all_monoid_prod(v, unit, [](U a, U b) { return a | b; }); } template U all_min(const std::vector &v) { return all_monoid_prod, T>(v, monoid::Min::unit(), monoid::Min::op); } template U all_max(const std::vector &v) { return all_monoid_prod, T>(v, monoid::Max::unit(), monoid::Max::op); } template U all_gcd(const std::vector &v, U unit = U()) { return all_monoid_prod(v, unit, [](U a, U b) { return std::gcd(a, b); }); } template U all_lcm(const std::vector &v, U unit = U(1)) { return all_monoid_prod(v, unit, [](U a, U b) { return std::lcm(a, b); }); } } // namespace kk2 #endif // KK2_TEMPLATE_FUNCTION_UTIL_HPP #ifndef KK2_TEMPLATE_IO_UTIL_HPP #define KK2_TEMPLATE_IO_UTIL_HPP 1 // なんかoj verifyはプロトタイプ宣言が落ちる namespace impl { struct read { template inline static void all_read(IStream &is, T &x) { is >> x; } template inline static void all_read(IStream &is, std::pair &p) { all_read(is, p.first); all_read(is, p.second); } template inline static void all_read(IStream &is, std::vector &v) { for (T &x : v) all_read(is, x); } template inline static void all_read(IStream &is, std::array &a) { for (T &x : a) all_read(is, x); } }; struct write { template inline static void all_write(OStream &os, const T &x) { os << x; } template inline static void all_write(OStream &os, const std::pair &p) { all_write(os, p.first); all_write(os, ' '); all_write(os, p.second); } template inline static void all_write(OStream &os, const std::vector &v) { for (int i = 0; i < (int)v.size(); ++i) { if (i) all_write(os, ' '); all_write(os, v[i]); } } template inline static void all_write(OStream &os, const std::array &a) { for (int i = 0; i < (int)F; ++i) { if (i) all_write(os, ' '); all_write(os, a[i]); } } }; } // namespace impl template * = nullptr> IStream &operator>>(IStream &is, std::pair &p) { impl::read::all_read(is, p); return is; } template * = nullptr> IStream &operator>>(IStream &is, std::vector &v) { impl::read::all_read(is, v); return is; } template * = nullptr> IStream &operator>>(IStream &is, std::array &a) { impl::read::all_read(is, a); return is; } template * = nullptr> OStream &operator<<(OStream &os, const std::pair &p) { impl::write::all_write(os, p); return os; } template * = nullptr> OStream &operator<<(OStream &os, const std::vector &v) { impl::write::all_write(os, v); return os; } template * = nullptr> OStream &operator<<(OStream &os, const std::array &a) { impl::write::all_write(os, a); return os; } #endif // KK2_TEMPLATE_IO_UTIL_HPP #ifndef KK2_TEMPLATE_MACROS_HPP #define KK2_TEMPLATE_MACROS_HPP 1 #define rep1(a) for (long long _ = 0; _ < (long long)(a); ++_) #define rep2(i, a) for (long long i = 0; i < (long long)(a); ++i) #define rep3(i, a, b) for (long long i = (a); i < (long long)(b); ++i) #define repi2(i, a) for (long long i = (a) - 1; i >= 0; --i) #define repi3(i, a, b) for (long long i = (a) - 1; i >= (long long)(b); --i) #define overload3(a, b, c, d, ...) d #define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) #define repi(...) overload3(__VA_ARGS__, repi3, repi2, rep1)(__VA_ARGS__) #define fi first #define se second #define all(p) begin(p), end(p) #endif // KK2_TEMPLATE_MACROS_HPP struct FastIOSetUp { FastIOSetUp() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } fast_io_set_up; auto &kin = std::cin; auto &kout = std::cout; auto (*kendl)(std::ostream &) = std::endl>; void Yes(bool b = 1) { kout << (b ? "Yes\n" : "No\n"); } void No(bool b = 1) { kout << (b ? "No\n" : "Yes\n"); } void YES(bool b = 1) { kout << (b ? "YES\n" : "NO\n"); } void NO(bool b = 1) { kout << (b ? "NO\n" : "YES\n"); } void yes(bool b = 1) { kout << (b ? "yes\n" : "no\n"); } void no(bool b = 1) { kout << (b ? "no\n" : "yes\n"); } template inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); } template inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); } std::istream &operator>>(std::istream &is, u128 &x) { std::string s; is >> s; x = 0; for (char c : s) { assert('0' <= c && c <= '9'); x = x * 10 + c - '0'; } return is; } std::istream &operator>>(std::istream &is, i128 &x) { std::string s; is >> s; bool neg = s[0] == '-'; x = 0; for (int i = neg; i < (int)s.size(); i++) { assert('0' <= s[i] && s[i] <= '9'); x = x * 10 + s[i] - '0'; } if (neg) x = -x; return is; } std::ostream &operator<<(std::ostream &os, u128 x) { if (x == 0) return os << '0'; std::string s; while (x) { s.push_back('0' + x % 10); x /= 10; } std::reverse(s.begin(), s.end()); return os << s; } std::ostream &operator<<(std::ostream &os, i128 x) { if (x == 0) return os << '0'; if (x < 0) { os << '-'; x = -x; } std::string s; while (x) { s.push_back('0' + x % 10); x /= 10; } std::reverse(s.begin(), s.end()); return os << s; } #endif // KK2_TEMPLATE_PROCON_HPP // #include #ifndef KK2_SEGMENT_TREE_LAZY_HPP #define KK2_SEGMENT_TREE_LAZY_HPP 1 namespace kk2 { template struct LazySegmentTree { public: LazySegmentTree() : LazySegmentTree(0) {} LazySegmentTree(int n) : _n(n) { log = 0; while ((1ll << log) < _n) log++; size = 1 << log; d = std::vector(2 * size, e()); lz = std::vector(size, id()); } template LazySegmentTree(int n, Args... args) : LazySegmentTree(std::vector(n, S(args...))) {} LazySegmentTree(const std::vector &v) : _n(int(v.size())) { log = 0; while ((1ll << log) < _n) log++; size = 1 << log; d = std::vector(2 * size, e()); lz = std::vector(size, id()); for (int i = 0; i < _n; i++) d[size + i] = v[i]; build(); } void build() { assert(!is_built); is_built = true; for (int i = size - 1; i >= 1; i--) { update(i); } } template void init_set(int p, Args... args) { assert(0 <= p && p < _n); assert(!is_built); d[p + size] = S(args...); } using Monoid = S; static S Op(S l, S r) { return op(l, r); } static S MonoidUnit() { return e(); } using Hom = F; static S Map(F f, S x) { return mapping(f, x); } static F Composition(F l, F r) { return composition(l, r); } static F HomUnit() { return id(); } template void set(int p, Args... args) { assert(0 <= p && p < _n); assert(is_built); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = S(args...); for (int i = 1; i <= log; i++) update(p >> i); } S get(int p) { assert(0 <= p && p < _n); assert(is_built); p += size; for (int i = log; i >= 1; i--) push(p >> i); return d[p]; } S prod(int l, int r) { assert(0 <= l && l <= r && r <= _n); assert(is_built); if (l == r) return e(); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push(r >> i); } S sml = e(), smr = e(); while (l < r) { if (l & 1) sml = op(sml, d[l++]); if (r & 1) smr = op(d[--r], smr); l >>= 1; r >>= 1; } return op(sml, smr); } S all_prod() { assert(is_built); return d[1]; } template void apply_point(int p, Args... args) { assert(0 <= p && p < _n); assert(is_built); p += size; for (int i = log; i >= 1; i--) push(p >> i); d[p] = mapping(F(args...), d[p]); for (int i = 1; i <= log; i++) update(p >> i); } template void apply_range(int l, int r, Args... args) { assert(0 <= l && l <= r && r <= _n); assert(is_built); if (l == r) return; F f = F(args...); l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } { int l2 = l, r2 = r; while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } l = l2; r = r2; } for (int i = 1; i <= log; i++) { if (((l >> i) << i) != l) update(l >> i); if (((r >> i) << i) != r) update((r - 1) >> i); } } template int max_right(int l) { return max_right(l, [](S x) { return g(x); }); } template int max_right(int l, G g) { assert(0 <= l && l <= _n); assert(g(e())); assert(is_built); if (l == _n) return _n; l += size; for (int i = log; i >= 1; i--) push(l >> i); S sm = e(); do { while (l % 2 == 0) l >>= 1; if (!g(op(sm, d[l]))) { while (l < size) { push(l); l = (2 * l); if (g(op(sm, d[l]))) { sm = op(sm, d[l]); l++; } } return l - size; } sm = op(sm, d[l]); l++; } while ((l & -l) != l); return _n; } template int min_left(int r) { return min_left(r, [](S x) { return g(x); }); } template int min_left(int r, G g) { assert(0 <= r && r <= _n); assert(g(e())); assert(is_built); if (r == 0) return 0; r += size; for (int i = log; i >= 1; i--) push((r - 1) >> i); S sm = e(); do { r--; while (r > 1 && (r % 2)) r >>= 1; if (!g(op(d[r], sm))) { while (r < size) { push(r); r = (2 * r + 1); if (g(op(d[r], sm))) { sm = op(d[r], sm); r--; } } return r + 1 - size; } sm = op(d[r], sm); } while ((r & -r) != r); return 0; } private: int _n, size, log; std::vector d; std::vector lz; bool is_built = false; void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); } void all_apply(int k, F f) { d[k] = mapping(f, d[k]); if (k < size) lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; template using LazySegmentTreeS = LazySegmentTree; } // namespace kk2 #endif // KK2_SEGMENT_TREE_LAZY_HPP using namespace std; using S = array; S op(S l, S r) { return l < r ? l : r; } S e() { return {infty, 0, 0}; } using F = int; S mapping(F f, S x) { return {x[0] + f, x[1], x[2]}; } F comp(F f, F g) { return f + g; } F id() { return 0; } void solve() { /* それぞれでHに到達するまでの回数を求める */ int n, h, t; kin >> n >> h >> t; vc a(n); kin >> a; vc> d(n); rep (i, n) d[i] = {(h + a[i] - 1) / a[i], -a[i] * ((h + a[i] - 1) / a[i]), (int)i}; kk2::LazySegmentTree seg(n); rep (i, n) seg.init_set(i, d[i]); seg.build(); vc c(n); rep (t) { auto [rest, r, idx] = seg.all_prod(); seg.apply_range(0, n, -rest); c[idx]++; seg.set(idx, d[idx]); } kout << c << kendl; } int main() { #ifdef KK2 int t = 1; #else int t = 1; #endif // kin >> t; rep (t) solve(); return 0; } // Author: kk2 // converted by https://github.com/kk2a/cpp-bundle // 2025-08-01 22:35:01