結果

問題 No.2248 max(C)-min(C)
ユーザー merom686merom686
提出日時 2023-03-18 00:44:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 3,000 ms
コード長 908 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 209,860 KB
実行使用メモリ 8,712 KB
最終ジャッジ日時 2023-10-18 16:43:00
合計ジャッジ時間 7,568 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 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 3 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 95 ms
7,920 KB
testcase_19 AC 13 ms
4,348 KB
testcase_20 AC 110 ms
8,712 KB
testcase_21 AC 106 ms
8,448 KB
testcase_22 AC 73 ms
6,932 KB
testcase_23 AC 46 ms
5,612 KB
testcase_24 AC 20 ms
4,348 KB
testcase_25 AC 100 ms
8,184 KB
testcase_26 AC 89 ms
7,656 KB
testcase_27 AC 100 ms
8,184 KB
testcase_28 AC 11 ms
4,348 KB
testcase_29 AC 91 ms
7,920 KB
testcase_30 AC 38 ms
5,084 KB
testcase_31 AC 111 ms
8,712 KB
testcase_32 AC 21 ms
4,352 KB
testcase_33 AC 35 ms
5,084 KB
testcase_34 AC 110 ms
8,712 KB
testcase_35 AC 110 ms
8,712 KB
testcase_36 AC 111 ms
8,712 KB
testcase_37 AC 57 ms
6,140 KB
testcase_38 AC 107 ms
8,712 KB
testcase_39 AC 106 ms
8,712 KB
testcase_40 AC 107 ms
8,712 KB
testcase_41 AC 90 ms
7,920 KB
testcase_42 AC 106 ms
8,712 KB
testcase_43 AC 93 ms
8,184 KB
testcase_44 AC 107 ms
8,712 KB
testcase_45 AC 81 ms
7,392 KB
testcase_46 AC 43 ms
5,612 KB
testcase_47 AC 107 ms
8,712 KB
testcase_48 AC 98 ms
8,712 KB
testcase_49 AC 109 ms
8,712 KB
testcase_50 AC 111 ms
8,712 KB
testcase_51 AC 110 ms
8,712 KB
testcase_52 AC 110 ms
8,712 KB
testcase_53 AC 19 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<pair<int, int>> p(n * 3);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        p[i] = { a, i };
    }
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        p[n + i] = { b, i };
        p[n * 2 + i] = { (p[i].first + b) / 2, i };
    }
    sort(p.begin(), p.end());

    vector<int> c(n, 0);
    int r = 1 << 30;
    int k = 0;
    int a1 = 0;
    int i1 = 0;
    for (int i0 = 0; i0 < n * 3; i0++) {
        while (k < n && i1 < n * 3) {
            auto [a, i] = p[i1++];
            a1 = max(a1, a);
            k += c[i]++ == 0;
        }
        if (k < n) break;
        auto [a, i] = p[i0];
        r = min(r, a1 - a);
        k -= --c[i] == 0;
    }
    cout << r << endl;

    return 0;
}
0