結果

問題 No.2248 max(C)-min(C)
ユーザー umimelumimel
提出日時 2023-03-17 22:43:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,364 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 170,804 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-10-18 15:45:02
合計ジャッジ時間 5,480 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 47 ms
7,436 KB
testcase_19 AC 8 ms
4,348 KB
testcase_20 AC 53 ms
7,964 KB
testcase_21 AC 51 ms
7,700 KB
testcase_22 AC 36 ms
6,380 KB
testcase_23 AC 24 ms
5,324 KB
testcase_24 AC 11 ms
4,348 KB
testcase_25 AC 49 ms
7,520 KB
testcase_26 AC 44 ms
6,936 KB
testcase_27 AC 49 ms
7,488 KB
testcase_28 AC 7 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 19 ms
4,952 KB
testcase_31 AC 54 ms
7,964 KB
testcase_32 WA -
testcase_33 AC 18 ms
4,796 KB
testcase_34 AC 54 ms
7,964 KB
testcase_35 AC 54 ms
7,964 KB
testcase_36 AC 54 ms
7,964 KB
testcase_37 AC 29 ms
5,784 KB
testcase_38 AC 48 ms
7,964 KB
testcase_39 AC 47 ms
7,964 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 48 ms
7,964 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 38 ms
6,908 KB
testcase_46 AC 21 ms
5,168 KB
testcase_47 AC 47 ms
7,964 KB
testcase_48 AC 43 ms
7,964 KB
testcase_49 AC 52 ms
7,964 KB
testcase_50 AC 53 ms
7,964 KB
testcase_51 AC 52 ms
7,964 KB
testcase_52 AC 53 ms
7,964 KB
testcase_53 AC 11 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll MAX_N = 2e5;

ll n;
vector<ll> a, b;
ll solve(ll base){
    vector<ll> c(n, 0);
    c[0] = base;
    for(ll i=1; i<n; i++){
        ll diff = INF, v = INF;
        if(abs(a[i]-base) < diff){
            diff = abs(a[i]-base);
            v = a[i];
        }
        if(abs(b[i]-base) < diff){
            diff = abs(b[i]-base);
            v = b[i];
        }
        if(abs((a[i]+b[i])/2-base) < diff){
            diff = abs((a[i]+b[i])/2-base);
            v = (a[i]+b[i])/2;
        }

        c[i] = v;
    }

    ll c_max = -INF, c_min = INF;
    rep(i, n){
        c_max = max(c_max, c[i]);
        c_min = min(c_min, c[i]);
    }

    return c_max-c_min;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    cin >> n;
    a.resize(n);
    b.resize(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = INF;
    ans = min(ans, solve(a[0]));
    ans = min(ans, solve(b[0]));
    ans = min(ans, solve((a[0]+b[0])/2));

    cout << ans << endl;
}
0