提出 #41550212


ソースコード 拡げる

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}

void solve(){
    int n, m;
    ll d;
    cin >> n >> m >> d;
    vector<ll> a(n), b(m);
    for(auto&i:a) cin >> i;
    for(auto&i:b) cin >> i;
    ll ans = -1;
    sort(begin(b), end(b));
    for(auto k:a)
    {
        int hi = upper_bound(begin(b), end(b), k + d) - begin(b) - 1;
        if(hi >= 0 and abs(b[hi] - k) <= d)
        {
            chmax(ans, k + b[hi]);
        }
    }
    cout << ans << endl;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

提出情報

提出日時
問題 D - Impartial Gift
ユーザ Motsu_xe
言語 C++ (GCC 9.2.1)
得点 400
コード長 829 Byte
結果 AC
実行時間 98 ms
メモリ 6384 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 4
AC × 44
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt, example_03.txt
All example_00.txt, example_01.txt, example_02.txt, example_03.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, only_00.txt, only_01.txt, only_02.txt, only_03.txt, only_04.txt, only_05.txt, random2_00.txt, random2_01.txt, random2_02.txt, random2_03.txt, random2_04.txt, random2_05.txt, random2_06.txt, random2_07.txt, random2_08.txt, random2_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 13 ms 3508 KiB
example_01.txt AC 2 ms 3536 KiB
example_02.txt AC 2 ms 3540 KiB
example_03.txt AC 2 ms 3476 KiB
hand_00.txt AC 2 ms 3540 KiB
hand_01.txt AC 71 ms 6300 KiB
hand_02.txt AC 87 ms 6308 KiB
hand_03.txt AC 88 ms 6384 KiB
hand_04.txt AC 63 ms 6264 KiB
hand_05.txt AC 66 ms 6304 KiB
hand_06.txt AC 44 ms 6380 KiB
hand_07.txt AC 46 ms 6280 KiB
hand_08.txt AC 45 ms 6308 KiB
only_00.txt AC 92 ms 6292 KiB
only_01.txt AC 90 ms 6376 KiB
only_02.txt AC 91 ms 6280 KiB
only_03.txt AC 98 ms 6312 KiB
only_04.txt AC 91 ms 6288 KiB
only_05.txt AC 92 ms 6284 KiB
random2_00.txt AC 57 ms 6316 KiB
random2_01.txt AC 53 ms 6316 KiB
random2_02.txt AC 54 ms 6200 KiB
random2_03.txt AC 54 ms 6224 KiB
random2_04.txt AC 58 ms 6200 KiB
random2_05.txt AC 54 ms 6284 KiB
random2_06.txt AC 51 ms 6284 KiB
random2_07.txt AC 54 ms 6312 KiB
random2_08.txt AC 54 ms 6224 KiB
random2_09.txt AC 54 ms 6384 KiB
random_00.txt AC 94 ms 6264 KiB
random_01.txt AC 92 ms 6280 KiB
random_02.txt AC 91 ms 6280 KiB
random_03.txt AC 91 ms 6380 KiB
random_04.txt AC 94 ms 6292 KiB
random_05.txt AC 94 ms 6304 KiB
random_06.txt AC 91 ms 6220 KiB
random_07.txt AC 90 ms 6196 KiB
random_08.txt AC 91 ms 6280 KiB
random_09.txt AC 96 ms 6312 KiB
random_10.txt AC 94 ms 6316 KiB
random_11.txt AC 91 ms 6312 KiB
random_12.txt AC 90 ms 6304 KiB
random_13.txt AC 91 ms 6316 KiB
random_14.txt AC 91 ms 6376 KiB