結果
問題 | No.3049 Contest Coordinator |
ユーザー |
|
提出日時 | 2025-03-07 21:53:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 233 ms / 2,000 ms |
コード長 | 2,922 bytes |
コンパイル時間 | 3,854 ms |
コンパイル使用メモリ | 284,192 KB |
実行使用メモリ | 12,740 KB |
最終ジャッジ日時 | 2025-03-07 21:53:46 |
合計ジャッジ時間 | 12,662 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 58 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<class F, class S> ostream &operator<<(ostream &s, const pair<F, S> &v) { s << "(" << v.first << ", " << v.second << ")"; return s; } template<ranges::range T> requires (!is_convertible_v<T, string_view>) istream &operator>>(istream &s, T &&v) { for (auto &&x : v) s >> x; return s; } template<ranges::range T> requires (!is_convertible_v<T, string_view>) ostream &operator<<(ostream &s, T &&v) { for (auto &&x : v) s << x << ' '; return s; } #ifdef LOCAL template<class... T> void dbg(T... x) { char e{}; ((cerr << e << x, e = ' '), ...); } #define debug(x...) dbg(#x, '=', x, '\n') #else #define debug(...) ((void)0) #endif #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define ff first #define ss second template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2; bool chmin(auto &a, auto b) { return (b < a and (a = b, true)); } bool chmax(auto &a, auto b) { return (a < b and (a = b, true)); } using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using i128 = __int128; using u128 = unsigned __int128; constexpr i64 mod = 998244353; void solve() { int N, T, X, Y; cin >> N >> T >> X >> Y; vector<int> D(N); cin >> D; sort(all(D)); vector<int> S; int lst = -inf<int>, cnt = 0; for (int p : D) { if (p - lst <= T) { cnt++; lst = p; } else { if (cnt) { S.push_back(cnt); } cnt = 1; lst = p; } } if (cnt) { S.push_back(cnt); } auto work = [&](auto &&self, auto l, auto r) -> vector<int> { if (r - l == 1) { return {0, *l}; } auto m = l + (r - l) / 2; auto L = self(self, l, m); auto R = self(self, m, r); vector<int> f{0}; auto i = L.begin() + 1; auto j = R.begin() + 1; auto get = [&](auto it) -> int { return *it - *prev(it); }; while (i != L.end() or j != R.end()) { if (j == R.end() or (i != L.end() and get(i) > get(j))) { f.push_back(f.back() + get(i)); i++; } else { f.push_back(f.back() + get(j)); j++; } } return f; }; auto conv = work(work, all(S)); vector<int> need(N + 1, N); for (int i = 0; i < conv.size(); i++) { need[conv[i]] = i; } for (int i = N - 1; i >= 0; i--) { chmin(need[i], need[i + 1]); } for (int i = 1; i <= N; i++) { cout << 1LL * min(X, Y) * (need[i] - 1) << " \n"[i == N]; } } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }