結果
| 問題 |
No.3325 陰陽師
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-23 17:26:21 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 235 ms / 2,000 ms |
| コード長 | 1,328 bytes |
| コンパイル時間 | 3,164 ms |
| コンパイル使用メモリ | 285,764 KB |
| 実行使用メモリ | 14,208 KB |
| 最終ジャッジ日時 | 2025-11-01 02:53:34 |
| 合計ジャッジ時間 | 8,834 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
[[nodiscard]] static inline uint_fast32_t prepare([[maybe_unused]] const uint_fast32_t N, const uint_fast32_t M, const std::vector<uint_least32_t>& S, const std::vector<uint_least32_t>& T) noexcept
{
[[assume(std::is_sorted(S.begin(), S.end()))]];
std::multiset<uint_least32_t> unused_S;
for (const auto& s : S) unused_S.insert(s);
uint_fast32_t x;
for (x = 0; x != M; ++x)
{
const auto itr = unused_S.lower_bound(T[x]);
if (itr == unused_S.end()) break;
unused_S.erase(itr);
}
return x;
}
[[nodiscard]] static inline uint_fast32_t solve(const uint_fast32_t N, const uint_fast32_t M, const std::vector<uint_least32_t>& S, std::vector<uint_least32_t>& T) noexcept
{
[[assume(std::is_sorted(S.begin(), S.end()))]];
const uint_fast32_t x = prepare(N, M, S, T);
std::sort(T.begin(), T.begin() + x);
uint_fast32_t ans = 0;
for (uint_fast32_t i = 0, j = 0; j != x; ++i, ++j)
{
while (S[i] < T[j]) ++i;
ans = std::max<uint_fast32_t>(ans, S[i] - T[j]);
}
return ans;
}
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), T(M);
for (auto& s : S) std::cin >> s;
for (auto& t : T) std::cin >> t;
std::sort(S.begin(), S.end());
std::cout << solve(N, M, S, T) << '\n';
return 0;
}