結果

問題 No.1597 Matrix Sort
ユーザー kotatsugamekotatsugame
提出日時 2021-07-09 21:39:45
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 664 ms / 1,500 ms
コード長 505 bytes
コンパイル時間 500 ms
使用メモリ 4,344 KB
最終ジャッジ日時 2023-02-01 22:35:17
合計ジャッジ時間 11,485 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,532 KB
testcase_01 AC 1 ms
3,568 KB
testcase_02 AC 1 ms
3,560 KB
testcase_03 AC 569 ms
4,236 KB
testcase_04 AC 625 ms
4,280 KB
testcase_05 AC 664 ms
4,164 KB
testcase_06 AC 645 ms
4,324 KB
testcase_07 AC 649 ms
4,232 KB
testcase_08 AC 413 ms
4,228 KB
testcase_09 AC 492 ms
4,312 KB
testcase_10 AC 192 ms
4,232 KB
testcase_11 AC 156 ms
4,272 KB
testcase_12 AC 350 ms
4,316 KB
testcase_13 AC 499 ms
4,316 KB
testcase_14 AC 575 ms
4,264 KB
testcase_15 AC 133 ms
4,280 KB
testcase_16 AC 222 ms
4,340 KB
testcase_17 AC 254 ms
4,344 KB
testcase_18 AC 610 ms
4,280 KB
testcase_19 AC 613 ms
4,164 KB
testcase_20 AC 612 ms
4,312 KB
testcase_21 AC 429 ms
4,288 KB
testcase_22 AC 217 ms
4,224 KB
testcase_23 AC 205 ms
4,208 KB
testcase_24 AC 37 ms
4,320 KB
testcase_25 AC 35 ms
4,284 KB
testcase_26 AC 2 ms
3,536 KB
testcase_27 AC 1 ms
3,532 KB
testcase_28 AC 1 ms
3,436 KB
testcase_29 AC 1 ms
3,536 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:20:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   20 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,P;
long K;
int A[1<<17],B[1<<17];
long cnt(int X)
{
	long ans=0;
	for(int i=0;i<N;i++)
	{
		if(A[i]<X)
		{
			ans+=lower_bound(B,B+N,X-A[i])-B;
		}
		ans+=lower_bound(B,B+N,P+X-A[i])-lower_bound(B,B+N,P-A[i]);
	}
	return ans;
}
main()
{
	cin>>N>>K>>P;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<N;i++)cin>>B[i];
	sort(B,B+N);
	int L=0,R=P;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		if(cnt(mid)>=K)R=mid;
		else L=mid;
	}
	cout<<L<<endl;
}
0