結果

問題 No.1597 Matrix Sort
ユーザー h2929h2929
提出日時 2021-07-09 22:18:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 406 ms / 1,500 ms
コード長 770 bytes
コンパイル時間 3,789 ms
コンパイル使用メモリ 228,804 KB
実行使用メモリ 4,884 KB
最終ジャッジ日時 2023-09-14 09:34:56
合計ジャッジ時間 11,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 368 ms
4,608 KB
testcase_04 AC 394 ms
4,624 KB
testcase_05 AC 406 ms
4,804 KB
testcase_06 AC 393 ms
4,680 KB
testcase_07 AC 396 ms
4,796 KB
testcase_08 AC 311 ms
4,736 KB
testcase_09 AC 324 ms
4,544 KB
testcase_10 AC 201 ms
4,544 KB
testcase_11 AC 166 ms
4,616 KB
testcase_12 AC 162 ms
4,740 KB
testcase_13 AC 305 ms
4,676 KB
testcase_14 AC 345 ms
4,604 KB
testcase_15 AC 122 ms
4,884 KB
testcase_16 AC 185 ms
4,628 KB
testcase_17 AC 206 ms
4,628 KB
testcase_18 AC 377 ms
4,844 KB
testcase_19 AC 258 ms
4,736 KB
testcase_20 AC 201 ms
4,620 KB
testcase_21 AC 193 ms
4,608 KB
testcase_22 AC 194 ms
4,628 KB
testcase_23 AC 181 ms
4,592 KB
testcase_24 AC 39 ms
4,628 KB
testcase_25 AC 36 ms
4,624 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 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