結果

問題 No.1597 Matrix Sort
ユーザー kotatsugamekotatsugame
提出日時 2021-07-09 21:39:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 664 ms / 1,500 ms
コード長 505 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 69,432 KB
実行使用メモリ 4,452 KB
最終ジャッジ日時 2023-09-14 08:09:37
合計ジャッジ時間 12,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 584 ms
4,376 KB
testcase_04 AC 630 ms
4,380 KB
testcase_05 AC 664 ms
4,380 KB
testcase_06 AC 647 ms
4,376 KB
testcase_07 AC 652 ms
4,380 KB
testcase_08 AC 417 ms
4,376 KB
testcase_09 AC 513 ms
4,380 KB
testcase_10 AC 194 ms
4,452 KB
testcase_11 AC 167 ms
4,380 KB
testcase_12 AC 362 ms
4,380 KB
testcase_13 AC 558 ms
4,380 KB
testcase_14 AC 651 ms
4,380 KB
testcase_15 AC 159 ms
4,452 KB
testcase_16 AC 232 ms
4,380 KB
testcase_17 AC 265 ms
4,380 KB
testcase_18 AC 618 ms
4,380 KB
testcase_19 AC 617 ms
4,380 KB
testcase_20 AC 613 ms
4,380 KB
testcase_21 AC 403 ms
4,380 KB
testcase_22 AC 236 ms
4,380 KB
testcase_23 AC 218 ms
4,380 KB
testcase_24 AC 37 ms
4,376 KB
testcase_25 AC 36 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,384 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