結果

問題 No.1597 Matrix Sort
ユーザー pockynypockyny
提出日時 2021-07-09 22:02:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 764 ms / 1,500 ms
コード長 775 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 82,060 KB
実行使用メモリ 5,156 KB
最終ジャッジ日時 2023-09-14 09:05:47
合計ジャッジ時間 12,567 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 639 ms
4,840 KB
testcase_04 AC 692 ms
4,780 KB
testcase_05 AC 755 ms
4,972 KB
testcase_06 AC 733 ms
4,972 KB
testcase_07 AC 764 ms
4,976 KB
testcase_08 AC 468 ms
4,984 KB
testcase_09 AC 544 ms
4,848 KB
testcase_10 AC 210 ms
4,856 KB
testcase_11 AC 156 ms
4,836 KB
testcase_12 AC 383 ms
4,972 KB
testcase_13 AC 551 ms
4,816 KB
testcase_14 AC 648 ms
4,956 KB
testcase_15 AC 144 ms
4,852 KB
testcase_16 AC 238 ms
4,844 KB
testcase_17 AC 269 ms
5,156 KB
testcase_18 AC 689 ms
4,972 KB
testcase_19 AC 700 ms
4,780 KB
testcase_20 AC 695 ms
4,768 KB
testcase_21 AC 421 ms
4,848 KB
testcase_22 AC 236 ms
5,136 KB
testcase_23 AC 234 ms
4,980 KB
testcase_24 AC 45 ms
4,912 KB
testcase_25 AC 44 ms
4,972 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll a[100010];
vector<ll> b;
int main(){
    ll i,n,k,p; cin >> n >> k >> p;
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++){
        ll x; cin >> x; b.push_back(x);
    }
    sort(b.begin(),b.end());
    ll l = -1,r = p;
    while(r - l>1){
        //cout << l << " " << r << endl;
        ll mid = (l + r)/2;
        ll num = 0;
        for(i=0;i<n;i++){
            if(a[i]<=mid) num += upper_bound(b.begin(),b.end(),mid - a[i]) - lower_bound(b.begin(),b.end(),0);
            num += upper_bound(b.begin(),b.end(),p + mid - a[i]) - lower_bound(b.begin(),b.end(),p - a[i]);
        }
        if(num>=k) r = mid;
        else l = mid;
    }
    cout << r << endl;
}
0