結果

問題 No.2248 max(C)-min(C)
ユーザー hiro71687khiro71687k
提出日時 2023-03-18 15:20:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 4,525 ms
コンパイル使用メモリ 266,588 KB
実行使用メモリ 10,192 KB
最終ジャッジ日時 2023-10-18 17:19:04
合計ジャッジ時間 23,332 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 5 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 8 ms
4,348 KB
testcase_07 AC 8 ms
4,348 KB
testcase_08 AC 10 ms
4,348 KB
testcase_09 AC 9 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 8 ms
4,348 KB
testcase_12 AC 6 ms
4,348 KB
testcase_13 AC 8 ms
4,348 KB
testcase_14 AC 10 ms
4,348 KB
testcase_15 AC 10 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 6 ms
4,348 KB
testcase_18 AC 756 ms
9,536 KB
testcase_19 AC 89 ms
4,348 KB
testcase_20 AC 786 ms
10,192 KB
testcase_21 AC 476 ms
9,768 KB
testcase_22 AC 510 ms
8,608 KB
testcase_23 AC 293 ms
6,280 KB
testcase_24 AC 139 ms
4,688 KB
testcase_25 AC 610 ms
9,640 KB
testcase_26 AC 648 ms
9,320 KB
testcase_27 AC 518 ms
9,608 KB
testcase_28 AC 78 ms
4,348 KB
testcase_29 AC 585 ms
9,408 KB
testcase_30 AC 301 ms
6,016 KB
testcase_31 AC 798 ms
10,192 KB
testcase_32 AC 132 ms
4,760 KB
testcase_33 AC 279 ms
5,400 KB
testcase_34 AC 734 ms
10,192 KB
testcase_35 AC 852 ms
10,192 KB
testcase_36 AC 795 ms
10,192 KB
testcase_37 AC 299 ms
6,848 KB
testcase_38 AC 396 ms
10,192 KB
testcase_39 AC 446 ms
10,192 KB
testcase_40 AC 430 ms
10,192 KB
testcase_41 AC 379 ms
9,472 KB
testcase_42 AC 439 ms
10,192 KB
testcase_43 AC 395 ms
9,568 KB
testcase_44 AC 494 ms
10,192 KB
testcase_45 AC 356 ms
8,968 KB
testcase_46 AC 199 ms
6,232 KB
testcase_47 AC 391 ms
10,192 KB
testcase_48 AC 364 ms
10,192 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.14159265359;
ll inf=1001000000000;
ll mod=1000000007;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),b(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    if (n==1)
    {
        cout <<0 << endl;
        return 0;
    }
    ll left=0,right=inf;
    ll ans=inf;
    while (right-left>1)
    {
        ll mid=(right+left)/2;
        bool ok=true;
        vector<ll>x;
        for (ll i = 0; i < n; i++)
        {
            vector<ll>c;
            if (a[i]>=mid)
            {
                c.push_back(a[i]);
            }
            if (b[i]>=mid)
            {
                c.push_back(b[i]);
            }
            if ((a[i]+b[i])/2>=mid)
            {
                c.push_back((a[i]+b[i])/2);
            }
            if (c.empty())
            {
                ok=false;
                break;
            }
            sort(c.begin(),c.end());
            x.push_back(c[0]);
        }
        if (!ok)
        {
            right=mid;
            continue;
        }else{
            left=mid;
        }
        sort(x.begin(),x.end());
        if (x[x.size()-1]-x[0]<ans)
        {
            ans=x[x.size()-1]-x[0];
        }
    }
    cout << ans << endl;
}
0