結果
| 問題 | No.1597 Matrix Sort |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-10 01:01:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 954 ms / 1,500 ms |
| コード長 | 1,009 bytes |
| 記録 | |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 78,456 KB |
| 最終ジャッジ日時 | 2025-01-22 23:19:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);
#define l_ength size
void mul_mod(ll& a, ll b){
a *= b;
a %= MOD;
}
void add_mod(ll& a, ll b){
a = (a<MOD)?a:(a-MOD);
b = (b<MOD)?b:(b-MOD);
a += b;
a = (a<MOD)?a:(a-MOD);
}
int n;
ll k,p,a[100100],b[100100];
bool check(ll x){
int i;
ll cnt=0ll;
for(i=0; i<n; ++i){
cnt += (ll)(std::lower_bound(b,b+n,x-a[i])-std::lower_bound(b,b+n,0ll-a[i]));
cnt += (ll)(std::lower_bound(b,b+n,p+x-a[i])-std::lower_bound(b,b+n,p-a[i]));
}
return (cnt<k);
}
int main(void){
int i;
ll ok=0ll,ng,mid;
std::cin >> n >> k >> p; ng = p;
for(i=0; i<n; ++i){
std::cin >> a[i];
}
for(i=0; i<n; ++i){
std::cin >> b[i];
}
std::sort(b,b+n);
while(ng-ok>1ll){
mid = (ok+ng)/2;
if(check(mid)){
ok = mid;
}else{
ng = mid;
}
}
std::cout << ok << std::endl;
return 0;
}