結果

問題 No.1597 Matrix Sort
ユーザー kenskens
提出日時 2021-07-10 01:17:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 394 ms / 1,500 ms
コード長 657 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 204,080 KB
実行使用メモリ 4,732 KB
最終ジャッジ日時 2023-09-14 12:47:49
合計ジャッジ時間 9,774 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 375 ms
4,704 KB
testcase_04 AC 390 ms
4,520 KB
testcase_05 AC 394 ms
4,680 KB
testcase_06 AC 380 ms
4,668 KB
testcase_07 AC 391 ms
4,684 KB
testcase_08 AC 308 ms
4,600 KB
testcase_09 AC 320 ms
4,644 KB
testcase_10 AC 232 ms
4,600 KB
testcase_11 AC 200 ms
4,592 KB
testcase_12 AC 176 ms
4,596 KB
testcase_13 AC 307 ms
4,596 KB
testcase_14 AC 346 ms
4,732 KB
testcase_15 AC 144 ms
4,592 KB
testcase_16 AC 214 ms
4,660 KB
testcase_17 AC 244 ms
4,660 KB
testcase_18 AC 370 ms
4,588 KB
testcase_19 AC 279 ms
4,548 KB
testcase_20 AC 237 ms
4,684 KB
testcase_21 AC 229 ms
4,544 KB
testcase_22 AC 232 ms
4,596 KB
testcase_23 AC 220 ms
4,540 KB
testcase_24 AC 42 ms
4,524 KB
testcase_25 AC 40 ms
4,648 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;

int main(){
  ll n, k, p;
  cin >> n >> k >> p;
  vector<ll> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll l = -1, r = p-1;
  while(r-l > 1) {
    ll m = (l + r)/2;
    ll cnt = 0;
    rep(i,n) {
      cnt += upper_bound(b.begin(),b.end(),m-a[i]) - lower_bound(b.begin(),b.end(),-a[i]);
      cnt += upper_bound(b.begin(),b.end(),p+m-a[i]) - lower_bound(b.begin(),b.end(),p-a[i]);;
    }
    if(cnt < k) l = m;
    else r = m;
  }
  cout << r << endl;
  return 0;
}
0