結果
問題 |
No.3297 Bake Cookies
|
ユーザー |
|
提出日時 | 2025-10-05 14:33:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,414 bytes |
コンパイル時間 | 2,900 ms |
コンパイル使用メモリ | 278,448 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-05 14:34:05 |
合計ジャッジ時間 | 4,974 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 27 |
ソースコード
#include <bits/stdc++.h> [[nodiscard]] static inline constexpr std::vector<uint_least32_t> prepare(const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector<uint_least32_t>& A) noexcept { std::vector<uint_least32_t> count_of(N, 0); for (const auto& a : A) ++count_of[a - 1]; return count_of; } [[nodiscard]] static inline constexpr bool check([[maybe_unused]] const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const uint_fast32_t T, const std::vector<uint_least32_t>& count_of, const uint_fast32_t c) noexcept { uint_fast32_t count = 0; for (const auto& num : count_of) if (num > c) count += num - c; for (const auto& num : count_of) if (num <= c) { if (count <= (c - num) / T) return true; else count -= (c - num) / T; } return false; } [[nodiscard]] static inline constexpr uint_fast32_t solve(const uint_fast32_t N, const uint_fast32_t M, const uint_fast32_t T, const std::vector<uint_least32_t>& count_of) noexcept { uint_fast32_t l = 0, r = M; while (l + 1 < r) { const auto c = (l + r) / 2; if (check(N, M, T, count_of, c)) r = c; else l = c; } return r; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); uint_fast32_t N, M, T; std::cin >> N >> M >> T; std::vector<uint_least32_t> A(M); for (auto& a : A) std::cin >> a; std::cout << solve(N, M, T, prepare(N, M, A)) << '\n'; return 0; }