結果
| 問題 |
No.3325 陰陽師
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-04 12:58:25 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 2,051 bytes |
| コンパイル時間 | 3,519 ms |
| コンパイル使用メモリ | 288,844 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-11-01 02:53:44 |
| 合計ジャッジ時間 | 7,035 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
[[nodiscard]] static inline constexpr bool check(const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector<uint_least32_t>& S, const std::vector<std::pair<uint_least32_t, uint_least32_t>>& T, const uint_fast32_t x) noexcept
{
[[assume(std::is_sorted(S.begin(), S.end()))]];
[[assume(std::is_sorted(T.begin(), T.end()))]];
uint_fast32_t i = 0;
for (const auto& [t, index] : T)
if (index < x)
{
while (i < N && S[i] < t) ++i;
if (i >= N) return false;
++i;
}
return true;
}
[[nodiscard]] static inline constexpr uint_fast64_t evaluate([[maybe_unused]] const uint_fast32_t N, [[maybe_unused]] const uint_fast32_t M, const std::vector<uint_least32_t>& S, const std::vector<std::pair<uint_least32_t, uint_least32_t>>& T, const uint_fast32_t x) noexcept
{
[[assume(std::is_sorted(S.begin(), S.end()))]];
[[assume(std::is_sorted(T.begin(), T.end()))]];
uint_fast32_t ans = 0, i = 0;
for (const auto& [t, index] : T)
if (index < x)
{
while (S[i] < t) ++i;
ans = std::max<uint_fast32_t>(ans, S[i++] - t);
}
return ans;
}
[[nodiscard]] static inline constexpr uint_fast64_t solve(const uint_fast32_t N, const uint_fast32_t M, const std::vector<uint_least32_t>& S, const std::vector<std::pair<uint_least32_t, uint_least32_t>>& T) noexcept
{
[[assume(std::is_sorted(S.begin(), S.end()))]];
[[assume(std::is_sorted(T.begin(), T.end()))]];
uint_fast32_t l = 0, r = M + 1;
while (l + 1 < r)
{
const uint_fast32_t x = (l + r) / 2;
if (check(N, M, S, T, x))
l = x;
else
r = x;
}
return evaluate(N, M, S, T, l);
}
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
uint_fast32_t N, M;
std::cin >> N >> M;
std::vector<uint_least32_t> S(N);
std::vector<std::pair<uint_least32_t, uint_least32_t>> T(M);
for (auto& s : S) std::cin >> s;
for (uint_fast32_t i = 0; i < M; ++i) std::cin >> T[i].first, T[i].second = i;
std::sort(S.begin(), S.end());
std::sort(T.begin(), T.end());
std::cout << solve(N, M, S, T) << '\n';
return 0;
}