結果

問題 No.1597 Matrix Sort
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-09 21:48:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 374 ms / 1,500 ms
コード長 634 bytes
コンパイル時間 2,102 ms
コンパイル使用メモリ 204,660 KB
実行使用メモリ 4,884 KB
最終ジャッジ日時 2023-09-14 08:28:00
合計ジャッジ時間 9,256 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 333 ms
4,884 KB
testcase_04 AC 349 ms
4,680 KB
testcase_05 AC 373 ms
4,680 KB
testcase_06 AC 362 ms
4,680 KB
testcase_07 AC 374 ms
4,600 KB
testcase_08 AC 290 ms
4,648 KB
testcase_09 AC 301 ms
4,560 KB
testcase_10 AC 199 ms
4,680 KB
testcase_11 AC 166 ms
4,632 KB
testcase_12 AC 158 ms
4,588 KB
testcase_13 AC 276 ms
4,692 KB
testcase_14 AC 313 ms
4,608 KB
testcase_15 AC 125 ms
4,760 KB
testcase_16 AC 184 ms
4,752 KB
testcase_17 AC 210 ms
4,752 KB
testcase_18 AC 336 ms
4,604 KB
testcase_19 AC 249 ms
4,680 KB
testcase_20 AC 205 ms
4,636 KB
testcase_21 AC 198 ms
4,676 KB
testcase_22 AC 199 ms
4,648 KB
testcase_23 AC 187 ms
4,676 KB
testcase_24 AC 41 ms
4,680 KB
testcase_25 AC 38 ms
4,552 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int N,K,P; cin>>N>>K>>P;
    vector<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.begin(),A.end());
    sort(B.begin(),B.end());
    int ok=P-1,ng=-1;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        int cnt=0;
        for(int i=0;i<N;i++){
            cnt+=upper_bound(B.begin(),B.end(),mid-A[i])-B.begin();
            cnt+=upper_bound(B.begin(),B.end(),mid+P-A[i])-lower_bound(B.begin(),B.end(),P-A[i]);
        }
        if(cnt>=K)ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}
0