結果

問題 No.2248 max(C)-min(C)
ユーザー otoshigootoshigo
提出日時 2023-03-17 21:48:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 3,000 ms
コード長 1,141 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 90,688 KB
実行使用メモリ 19,056 KB
最終ジャッジ日時 2023-10-18 14:21:52
合計ジャッジ時間 6,795 ms
ジャッジサーバーID
(参考情報)
judge12 / 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 2 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 107 ms
11,628 KB
testcase_19 AC 15 ms
5,128 KB
testcase_20 AC 123 ms
17,176 KB
testcase_21 AC 119 ms
19,056 KB
testcase_22 AC 81 ms
11,036 KB
testcase_23 AC 52 ms
7,056 KB
testcase_24 AC 22 ms
5,216 KB
testcase_25 AC 115 ms
18,928 KB
testcase_26 AC 98 ms
11,524 KB
testcase_27 AC 112 ms
18,896 KB
testcase_28 AC 12 ms
4,372 KB
testcase_29 AC 102 ms
11,564 KB
testcase_30 AC 43 ms
8,444 KB
testcase_31 AC 124 ms
17,176 KB
testcase_32 AC 24 ms
5,256 KB
testcase_33 AC 39 ms
8,396 KB
testcase_34 AC 122 ms
17,176 KB
testcase_35 AC 123 ms
17,176 KB
testcase_36 AC 122 ms
17,176 KB
testcase_37 AC 65 ms
10,548 KB
testcase_38 AC 118 ms
17,176 KB
testcase_39 AC 117 ms
17,176 KB
testcase_40 AC 120 ms
17,176 KB
testcase_41 AC 101 ms
11,596 KB
testcase_42 AC 118 ms
17,176 KB
testcase_43 AC 108 ms
18,848 KB
testcase_44 AC 120 ms
17,176 KB
testcase_45 AC 92 ms
11,476 KB
testcase_46 AC 49 ms
7,032 KB
testcase_47 AC 119 ms
17,176 KB
testcase_48 AC 100 ms
17,176 KB
testcase_49 AC 123 ms
17,176 KB
testcase_50 AC 123 ms
17,176 KB
testcase_51 AC 124 ms
17,176 KB
testcase_52 AC 122 ms
17,176 KB
testcase_53 AC 21 ms
5,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>A(n),B(n);
    rep(i,n)cin>>A[i];
    rep(i,n)cin>>B[i];
    vector<tuple<int,int,int>>V;
    int m=1<<30;
    rep(i,n){
        if(A[i]<B[i])swap(A[i],B[i]);
        chmin(m,A[i]);
        V.push_back(make_tuple(A[i],i,0));
        V.push_back(make_tuple((A[i]+B[i])/2,i,1));
        V.push_back(make_tuple(B[i],i,2));
    }
    sort(rall(V));
    int ans=1<<30;
    for(auto[p,i,t]:V){
        chmin(ans,p-m);
        if(t==0){
            chmin(m,(A[i]+B[i])/2);
        }else if(t==1){
            chmin(m,B[i]);
        }else{
            break;
        }
    }
    cout<<ans<<"\n";
}
0