結果

問題 No.2248 max(C)-min(C)
ユーザー ei1333333ei1333333
提出日時 2023-03-17 21:48:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 520 ms / 3,000 ms
コード長 715 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 210,424 KB
実行使用メモリ 19,708 KB
最終ジャッジ日時 2023-10-18 14:22:35
合計ジャッジ時間 13,688 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 4 ms
4,348 KB
testcase_15 AC 4 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 218 ms
17,596 KB
testcase_19 AC 26 ms
5,196 KB
testcase_20 AC 245 ms
19,708 KB
testcase_21 AC 231 ms
18,916 KB
testcase_22 AC 167 ms
14,164 KB
testcase_23 AC 96 ms
10,204 KB
testcase_24 AC 37 ms
6,104 KB
testcase_25 AC 231 ms
18,124 KB
testcase_26 AC 196 ms
16,540 KB
testcase_27 AC 222 ms
18,124 KB
testcase_28 AC 21 ms
4,924 KB
testcase_29 AC 214 ms
17,068 KB
testcase_30 AC 77 ms
8,884 KB
testcase_31 AC 250 ms
19,708 KB
testcase_32 AC 42 ms
6,508 KB
testcase_33 AC 70 ms
8,356 KB
testcase_34 AC 268 ms
19,708 KB
testcase_35 AC 265 ms
19,708 KB
testcase_36 AC 265 ms
19,708 KB
testcase_37 AC 122 ms
11,788 KB
testcase_38 AC 389 ms
19,708 KB
testcase_39 AC 379 ms
19,708 KB
testcase_40 AC 401 ms
19,708 KB
testcase_41 AC 323 ms
17,332 KB
testcase_42 AC 382 ms
19,708 KB
testcase_43 AC 337 ms
17,860 KB
testcase_44 AC 385 ms
19,708 KB
testcase_45 AC 272 ms
16,012 KB
testcase_46 AC 122 ms
9,940 KB
testcase_47 AC 393 ms
19,708 KB
testcase_48 AC 278 ms
19,708 KB
testcase_49 AC 489 ms
19,708 KB
testcase_50 AC 520 ms
19,708 KB
testcase_51 AC 520 ms
19,708 KB
testcase_52 AC 478 ms
19,708 KB
testcase_53 AC 52 ms
6,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector< int64 > A(N), B(N);
  for(auto& a: A) cin >> a;
  for(auto& b: B) cin >> b;
  int64 val = 1ll << 60;
  vector< int > used(N);
  multimap< int64, int > st;
  for(int i = 0; i < N; i++) {
    if(A[i] > B[i]) {
      swap(A[i], B[i]);
    }
    st.emplace(A[i], i);
  }
  val = min(val,st.rbegin()->first-st.begin()->first);
  for(;;) {
    auto [v, i] = *st.begin();
    st.erase(st.begin());
    if(used[i] == 3) break;
    used[i]++;
    if(used[i] == 1) st.emplace((A[i]+B[i])/2,i);
    else st.emplace(B[i],i);
    val = min(val,st.rbegin()->first-st.begin()->first);
  }
  cout << val << endl;
}
0