結果
| 問題 |
No.1597 Matrix Sort
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 21:39:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 689 ms / 1,500 ms |
| コード長 | 505 bytes |
| コンパイル時間 | 609 ms |
| コンパイル使用メモリ | 69,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-01 15:35:36 |
| 合計ジャッジ時間 | 11,627 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
20 | main()
| ^~~~
ソースコード
#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;
}