結果
| 問題 |
No.3325 陰陽師
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-11-05 00:46:41 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 407 ms / 2,000 ms |
| コード長 | 890 bytes |
| コンパイル時間 | 3,379 ms |
| コンパイル使用メモリ | 286,780 KB |
| 実行使用メモリ | 19,584 KB |
| 最終ジャッジ日時 | 2025-11-05 00:46:57 |
| 合計ジャッジ時間 | 14,347 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}