結果
| 問題 |
No.3221 Count Turns
|
| コンテスト | |
| ユーザー |
nono00
|
| 提出日時 | 2025-08-01 22:17:21 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 9,278 bytes |
| コンパイル時間 | 3,228 ms |
| コンパイル使用メモリ | 284,576 KB |
| 実行使用メモリ | 10,096 KB |
| 最終ジャッジ日時 | 2025-08-01 22:17:30 |
| 合計ジャッジ時間 | 4,843 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 6 WA * 30 |
ソースコード
#include <bit>
#include <cassert>
#include <vector>
namespace nono {
/// brief : 一点更新 区間取得のsegment tree. <https://atcoder.github.io/ac-library/master/document_ja/segtree.html>
template <class M>
class SegmentTree {
using T = M::Value;
public:
SegmentTree(): SegmentTree(0) {}
explicit SegmentTree(int n): SegmentTree(std::vector<T>(n, M::e())) {}
explicit SegmentTree(const std::vector<T>& v): n_(int(v.size())) {
size_ = std::bit_ceil((unsigned int)(n_));
log_ = std::countr_zero((unsigned int)size_);
data_ = std::vector<T>(2 * size_, M::e());
for (int i = 0; i < n_; i++) data_[size_ + i] = v[i];
for (int i = size_ - 1; i >= 1; i--) {
update(i);
}
}
/// # set(p, x)
/// data[p] <= x
/// O(logn)
void set(int p, T x) {
assert(0 <= p && p < n_);
p += size_;
data_[p] = x;
for (int i = 1; i <= log_; i++) update(p >> i);
}
/// # get(p)
/// return data[p]
/// O(logn)
T get(int p) const {
assert(0 <= p && p < n_);
return data_[p + size_];
}
/// # prod(l, r)
/// return op[for i in [l, r)](data[i])
/// O(logn)
T prod(int l, int r) const {
assert(0 <= l && l <= r && r <= n_);
T sml = M::e(), smr = M::e();
l += size_;
r += size_;
while (l < r) {
if (l & 1) sml = M::op(sml, data_[l++]);
if (r & 1) smr = M::op(data_[--r], smr);
l >>= 1;
r >>= 1;
}
return M::op(sml, smr);
}
/// # all_prod()
/// O(1)
T all_prod() const {
return data_[1];
}
/// # apply(p, f)
/// data[p] <= mapping(f, data[p])
/// O(logn)
template <class F>
int max_right(int l, F f) const {
assert(0 <= l && l <= n_);
assert(f(M::e()));
if (l == n_) return n_;
l += size_;
T sm = M::e();
do {
while (l % 2 == 0) l >>= 1;
if (!f(M::op(sm, data_[l]))) {
while (l < size_) {
l = (2 * l);
if (f(M::op(sm, data_[l]))) {
sm = M::op(sm, data_[l]);
l++;
}
}
return l - size_;
}
sm = M::op(sm, data_[l]);
l++;
} while ((l & -l) != l);
return n_;
}
/// # apply(l, r, f)
/// [for i in [l, r)](data[i] <= mapping(f, data[i])
/// O(logn)
template <class F>
int min_left(int r, F f) const {
assert(0 <= r && r <= n_);
assert(f(M::e()));
if (r == 0) return 0;
r += size_;
T sm = M::e();
do {
r--;
while (r > 1 && (r % 2)) r >>= 1;
if (!f(M::op(data_[r], sm))) {
while (r < size_) {
r = (2 * r + 1);
if (f(M::op(data_[r], sm))) {
sm = M::op(data_[r], sm);
r--;
}
}
return r + 1 - size_;
}
sm = M::op(data_[r], sm);
} while ((r & -r) != r);
return 0;
}
private:
int n_, size_, log_;
std::vector<T> data_;
void update(int k) {
data_[k] = M::op(data_[2 * k], data_[2 * k + 1]);
}
};
} // namespace nono
#include <algorithm>
#include <limits>
#include <numeric>
#include <optional>
namespace nono {
namespace monoid {
struct MonoidTemplate {
struct Value {};
static Value op(Value lhs, Value rhs);
static Value e();
};
/// # Min
template <class T>
struct Min {
using Value = T;
static Value op(Value lhs, Value rhs) {
return std::min(lhs, rhs);
}
static Value e() {
return std::numeric_limits<T>::max();
}
};
/// # Max
template <class T>
struct Max {
using Value = T;
static Value op(Value lhs, Value rhs) {
return std::max(lhs, rhs);
}
static Value e() {
return std::numeric_limits<T>::min();
}
};
/// # MinMax
template <class T>
struct MinMax {
struct Value {
Value(): min(std::numeric_limits<T>::max()), max(std::numeric_limits<T>::min()) {}
Value(T val): min(val), max(val) {}
Value(T min, T max): min(min), max(max) {}
T min, max;
};
static Value op(Value lhs, Value rhs) {
return Value{std::min(lhs.min, rhs.min), std::max(lhs.max, rhs.max)};
}
static Value e() {
return Value{};
}
};
/// # Add
template <class T>
struct Add {
using Value = T;
static Value op(Value lhs, Value rhs) {
return lhs + rhs;
}
static Value e() {
return static_cast<Value>(0);
}
};
/// # Mul
template <class T>
struct Mul {
using Value = T;
static Value op(Value lhs, Value rhs) {
return lhs * rhs;
}
static Value e() {
return static_cast<Value>(1);
}
};
/// # Composite
/// (ax + b) 関数の合成
template <class T>
struct Composite {
struct Value {
Value(T a = 1, T b = 0): a(a), b(b) {}
T a;
T b;
T eval(T x) {
return a * x + b;
}
};
static Value op(Value lhs, Value rhs) {
return {lhs.a * rhs.a, rhs.a * lhs.b + rhs.b};
}
static Value e() {
return Value{};
}
};
/// # MinIndex
/// (a, i), (b, j)
/// [1] if a <= b:
/// return (a, i)
/// [2] else
/// return (b, j)
/// 同じなら左側
template <class T>
struct MinIndex {
struct Value {
Value(T value, int index): value(value), index(index) {}
T value;
int index;
};
static Value op(Value lhs, Value rhs) {
return (lhs.value <= rhs.value ? lhs : rhs);
}
static Value e() {
return {std::numeric_limits<T>::max(), -1};
}
};
template <class T>
struct MaxIndex {
struct Value {
T value;
int index;
};
static Value op(Value lhs, Value rhs) {
return (lhs.value >= rhs.value ? lhs : rhs);
}
static Value e() {
return {std::numeric_limits<T>::min(), -1};
}
};
/// # Rev
template <class M>
struct Rev {
using T = M::Value;
struct Value {
Value(): ord(M::e()), rev(M::e()) {}
Value(T v_): ord(v_), rev(v_) {}
T ord, rev;
};
static Value op(Value lhs, Value rhs) {
lhs.ord = M::op(lhs.ord, rhs.ord);
lhs.rev = M::op(rhs.rev, lhs.rev);
return lhs;
}
static Value e() {
return Value{};
}
};
/// # Gcd
template <class T>
struct Gcd {
using Value = T;
static Value op(Value lhs, Value rhs) {
return std::gcd(lhs, rhs);
}
static Value e() {
return Value{0};
}
};
/// # MaxSubSeq
/// max[for r in [0, n), for r in [l + 1, n]](sum[for i in [l, r)](data[i]))
template <class T>
struct MaxSubSeq {
struct Value {
Value(T v = 0): val(std::max(T{0}, v)), prefix(std::min(T{0}, v)), suffix(std::max(T{0}, v)), sum(v) {}
T max_subseq_sum() const {
return val;
}
T val, prefix, suffix, sum;
};
static Value op(Value lhs, Value rhs) {
Value result{};
result.prefix = std::min(lhs.prefix, lhs.sum + rhs.prefix);
result.suffix = std::max(lhs.suffix, lhs.sum + rhs.suffix);
result.sum = lhs.sum + rhs.sum;
result.val = std::max({lhs.val, rhs.val, (rhs.suffix + lhs.sum) - (lhs.prefix)});
return result;
}
static Value e() {
return Value{};
}
};
} // namespace monoid
} // namespace nono
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, vector<T>, greater<T>>;
#define rep2(i, n) for (ll i = 0; i < (n); i++)
#define rep3(i, l, r) for (ll i = (l); i < (r); i++)
#define rrep2(i, n) for (ll i = n; i-- > 0;)
#define rrep3(i, r, l) for (ll i = (r); i-- > (l);)
#define overload(a, b, c, d, ...) d
#define rep(...) overload(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rrep(...) overload(__VA_ARGS__, rrep3, rrep2)(__VA_ARGS__)
#define all(x) begin(x), end(x)
bool chmin(auto& lhs, auto rhs) {
return lhs > rhs ? lhs = rhs, 1 : 0;
}
bool chmax(auto& lhs, auto rhs) {
return lhs < rhs ? lhs = rhs, 1 : 0;
}
struct IOIO {
IOIO() {
std::cin.tie(0)->sync_with_stdio(0);
}
} ioio;
void solve() {
using M = nono::monoid::MinIndex<ll>;
using Segtree = nono::SegmentTree<M>;
int n;
ll h;
int t;
cin >> n >> h >> t;
vector<ll> a(n);
rep(i, n) cin >> a[i];
vector<int> c(n);
Segtree segtree(n);
rep(i, n) {
segtree.set(i, {(h + a[i] - 1) / a[i], (int)i});
}
ll offset = 0;
rep(i, t) {
auto res = segtree.all_prod();
c[res.index]++;
offset = res.value;
res.value = offset + ((h + a[res.index] - 1) / a[res.index]);
segtree.set(res.index, res);
}
rep(i, n) cout << c[i] << " \n"[i + 1 == n];
}
int main() {
int t = 1;
// cin >> t;
while (t--) solve();
}
nono00