結果

問題 No.3325 陰陽師
コンテスト
ユーザー karinohito
提出日時 2025-11-01 15:31:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 776 bytes
コンパイル時間 2,867 ms
コンパイル使用メモリ 288,572 KB
実行使用メモリ 23,552 KB
最終ジャッジ日時 2025-11-01 15:31:52
合計ジャッジ時間 10,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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



int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N,M;
    cin>>N>>M;
    vector<ll> T(M);
    multiset<ll> S;
    ll s;
    for(int i=0;i<N;i++)cin>>s,S.insert(s);
    for(int i=0;i<M;i++)cin>>T[i];
    auto NS=S;
    for(int i=0;i<M;i++){
        auto p=S.lower_bound(T[i]);
        if(p==S.end()){
            T.resize(i);
            break;
        }
        else{
            S.erase(p);
        }
    }
    if(T.size()==0){
        cout<<0<<endl;
        return 0;
    }
    S=NS;
    sort(T.begin(),T.end());
    ll an=0;
    for(int i=0;i<T.size();i++){
        auto p=S.lower_bound(T[i]);
        S.erase(p);
        an=max(an,(*p)-T[i]);
    }
    cout<<an<<endl;
}



0