結果
| 問題 | No.3325 陰陽師 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-05 00:46:41 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 209 ms / 2,000 ms |
| + 602µs | |
| コード長 | 890 bytes |
| 記録 | |
| コンパイル時間 | 2,383 ms |
| コンパイル使用メモリ | 343,756 KB |
| 実行使用メモリ | 19,712 KB |
| 最終ジャッジ日時 | 2026-07-16 08:02:44 |
| 合計ジャッジ時間 | 9,150 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<long long> S(N), T(M);
for (int i = 0; i < N; i++) cin >> S[i];
for (int i = 0; i < M; i++) cin >> T[i];
if (T[0] > *max_element(S.begin(), S.end())) {
cout << 0 << "\n";
return 0;
}
multiset<long long> L(S.begin(), S.end());
vector<long long> TT;
for (auto i : T) {
auto it = L.lower_bound(i);
if (it == L.end()) break;
L.erase(it);
TT.push_back(i);
}
sort(TT.begin(), TT.end());
L = multiset<long long>(S.begin(), S.end());
long long ans = 0;
for (auto i : TT) {
auto it = L.lower_bound(i);
long long a = *it;
L.erase(it);
ans = max(ans, a - i);
}
cout << ans << "\n";
return 0;
}