結果

問題 No.1597 Matrix Sort
ユーザー totori_nyaatotori_nyaa
提出日時 2021-07-09 21:58:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 915 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 168,628 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-14 08:58:43
合計ジャッジ時間 7,282 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 345 ms
4,432 KB
testcase_04 AC 356 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 189 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 189 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);

	int n,k,mod;
	cin>>n>>k>>mod;
	int a[n],b[n];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	sort(a,a+n);
	sort(b,b+n);
	int low = -1, up = 1e9+7, mid=-1;
	while(up-low>1){
		mid = (low + up) / 2;
		ll cnt = 0;
		for(int i=0;i<n;i++){
			cnt += upper_bound(b,b+n,mid-a[i]) - b;
			cnt += upper_bound(b,b+n,mid-a[i]+mod) - lower_bound(b,b+n,mod-a[i]);
		}
		if(cnt < k)low = mid;
		else up = mid;
	}
	cout << up << endl;
}
0