結果

問題 No.1597 Matrix Sort
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-09 21:48:36
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 375 ms / 1,500 ms
コード長 634 bytes
コンパイル時間 3,164 ms
使用メモリ 6,952 KB
最終ジャッジ日時 2023-02-01 22:56:57
合計ジャッジ時間 9,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
4,900 KB
testcase_01 AC 1 ms
4,904 KB
testcase_02 AC 2 ms
4,900 KB
testcase_03 AC 350 ms
4,904 KB
testcase_04 AC 364 ms
4,904 KB
testcase_05 AC 375 ms
6,948 KB
testcase_06 AC 363 ms
6,952 KB
testcase_07 AC 374 ms
4,900 KB
testcase_08 AC 307 ms
6,948 KB
testcase_09 AC 318 ms
6,952 KB
testcase_10 AC 197 ms
4,904 KB
testcase_11 AC 169 ms
4,900 KB
testcase_12 AC 163 ms
4,900 KB
testcase_13 AC 289 ms
4,900 KB
testcase_14 AC 324 ms
4,904 KB
testcase_15 AC 122 ms
6,952 KB
testcase_16 AC 184 ms
4,900 KB
testcase_17 AC 209 ms
4,904 KB
testcase_18 AC 350 ms
4,900 KB
testcase_19 AC 259 ms
6,952 KB
testcase_20 AC 204 ms
4,904 KB
testcase_21 AC 195 ms
4,900 KB
testcase_22 AC 197 ms
4,900 KB
testcase_23 AC 184 ms
4,900 KB
testcase_24 AC 39 ms
4,904 KB
testcase_25 AC 36 ms
4,904 KB
testcase_26 AC 2 ms
4,904 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 2 ms
6,948 KB
testcase_29 AC 2 ms
4,904 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