結果

問題 No.1597 Matrix Sort
ユーザー h2929h2929
提出日時 2021-07-09 22:18:59
言語 C++14
(gcc 12.2.0 + boost 1.81.0)
結果
AC  
実行時間 416 ms / 1,500 ms
コード長 770 bytes
コンパイル時間 3,591 ms
実行使用メモリ 6,952 KB
最終ジャッジ日時 2023-02-02 00:10:23
合計ジャッジ時間 10,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,900 KB
testcase_01 AC 2 ms
6,948 KB
testcase_02 AC 1 ms
4,904 KB
testcase_03 AC 367 ms
4,904 KB
testcase_04 AC 398 ms
4,904 KB
testcase_05 AC 416 ms
4,904 KB
testcase_06 AC 403 ms
4,904 KB
testcase_07 AC 403 ms
4,900 KB
testcase_08 AC 310 ms
4,904 KB
testcase_09 AC 322 ms
6,948 KB
testcase_10 AC 201 ms
6,948 KB
testcase_11 AC 167 ms
4,904 KB
testcase_12 AC 165 ms
6,948 KB
testcase_13 AC 308 ms
6,948 KB
testcase_14 AC 350 ms
6,948 KB
testcase_15 AC 124 ms
6,952 KB
testcase_16 AC 186 ms
6,948 KB
testcase_17 AC 211 ms
4,900 KB
testcase_18 AC 379 ms
4,904 KB
testcase_19 AC 259 ms
6,952 KB
testcase_20 AC 204 ms
4,904 KB
testcase_21 AC 195 ms
4,904 KB
testcase_22 AC 197 ms
4,900 KB
testcase_23 AC 186 ms
6,948 KB
testcase_24 AC 39 ms
4,904 KB
testcase_25 AC 37 ms
4,900 KB
testcase_26 AC 2 ms
4,904 KB
testcase_27 AC 1 ms
4,904 KB
testcase_28 AC 1 ms
4,904 KB
testcase_29 AC 1 ms
4,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define INF 1000000000000000000
using namespace atcoder;
using namespace std;

int main(void){
  ll n, k, p;
  cin >> n >> k >> p;
  vector<ll> a(n);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<ll> b(n);
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  ll l = 0, r = p, m;
  while (l + 1 < r){
    m = (l + r)/2;
    ll t = 0;
    for (ll i = 0; i < n; i++){
      t += lower_bound(b.begin(), b.end(), m-a[i]) - b.begin();
      t += lower_bound(b.begin(), b.end(), p+m-a[i]) - lower_bound(b.begin(), b.end(), p-a[i]);
    }
    if (t >= k)
      r = m;
    else
      l = m;
  }
  cout << r-1 << endl;

  return 0;
}
0