結果

問題 No.2248 max(C)-min(C)
ユーザー 👑 NachiaNachia
提出日時 2023-03-17 22:19:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 113 ms / 3,000 ms
コード長 1,169 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 88,544 KB
実行使用メモリ 15,604 KB
最終ジャッジ日時 2023-10-18 15:14:03
合計ジャッジ時間 6,481 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_04 AC 2 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 2 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 98 ms
14,088 KB
testcase_19 AC 14 ms
4,524 KB
testcase_20 AC 112 ms
15,604 KB
testcase_21 AC 106 ms
15,076 KB
testcase_22 AC 74 ms
11,516 KB
testcase_23 AC 47 ms
8,420 KB
testcase_24 AC 20 ms
5,316 KB
testcase_25 AC 102 ms
14,616 KB
testcase_26 AC 90 ms
13,296 KB
testcase_27 AC 101 ms
14,352 KB
testcase_28 AC 11 ms
4,348 KB
testcase_29 AC 93 ms
13,560 KB
testcase_30 AC 37 ms
7,360 KB
testcase_31 AC 112 ms
15,604 KB
testcase_32 AC 22 ms
5,580 KB
testcase_33 AC 35 ms
7,096 KB
testcase_34 AC 113 ms
15,604 KB
testcase_35 AC 112 ms
15,604 KB
testcase_36 AC 112 ms
15,604 KB
testcase_37 AC 58 ms
9,736 KB
testcase_38 AC 108 ms
15,604 KB
testcase_39 AC 109 ms
15,604 KB
testcase_40 AC 108 ms
15,604 KB
testcase_41 AC 92 ms
13,824 KB
testcase_42 AC 109 ms
15,604 KB
testcase_43 AC 95 ms
14,352 KB
testcase_44 AC 108 ms
15,604 KB
testcase_45 AC 84 ms
13,032 KB
testcase_46 AC 44 ms
8,416 KB
testcase_47 AC 109 ms
15,604 KB
testcase_48 AC 84 ms
15,604 KB
testcase_49 AC 110 ms
15,604 KB
testcase_50 AC 110 ms
15,604 KB
testcase_51 AC 110 ms
15,604 KB
testcase_52 AC 110 ms
15,604 KB
testcase_53 AC 19 ms
5,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <atcoder/modint>
using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

int main(){
    int N; cin >> N;
    vector<i64> A(N); rep(i,N) cin >> A[i];
    vector<i64> B(N); rep(i,N) cin >> B[i];
    rep(i,N) if(A[i] > B[i]) swap(A[i], B[i]);
    vector<pair<i64,i64>> Que(N*3);
    i64 preservedMax = 0;
    rep(i,N){
        preservedMax = max(preservedMax, A[i]);
        Que[i*3+0] = { A[i], (A[i] + B[i]) / 2 };
        Que[i*3+1] = { (A[i] + B[i]) / 2, B[i] };
        Que[i*3+2] = { B[i], INF };
    }
    sort(Que.begin(), Que.end());
    i64 ans = INF;
    for(auto [a,b] : Que){
        ans = min(ans, preservedMax - a);
        preservedMax = max(preservedMax, b);
    }
    cout << ans << endl;
    return 0;
}



struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0