結果

問題 No.3325 陰陽師
コンテスト
ユーザー forest3
提出日時 2025-11-13 14:41:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 491 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 171,276 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2025-11-13 14:42:11
合計ジャッジ時間 14,349 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;

int main(){
	int n, m;
	cin >> n >> m;
	multiset<int> st, st1;
	vector<int> t(m);
	rep(i, 0, n) {
		int s;
		cin >> s;
		st.insert(s);
	}
	st1 = st;
	rep(i, 0, m) cin >> t[i];
	int ans = 0, num = m;
	rep(i, 0, m) {
		auto it = st.lower_bound(t[i]);
		if(it == st.end()) {
			num = i;
			break;
		}
		st.erase(it);
	}
	sort(t.begin(), t.begin() + num);
	rep(i, 0, num) {
		auto it = st1.lower_bound(t[i]);
		if(it == st1.end()) break;
		ans = max(ans, *it - t[i]);
		st1.erase(it);
	}	
	cout << ans << endl;
}
0