結果

問題 No.1597 Matrix Sort
ユーザー chocoruskchocorusk
提出日時 2021-07-09 21:35:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 389 ms / 1,500 ms
コード長 1,224 bytes
コンパイル時間 3,401 ms
コンパイル使用メモリ 189,208 KB
実行使用メモリ 4,448 KB
最終ジャッジ日時 2023-09-14 07:56:52
合計ジャッジ時間 11,170 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 368 ms
4,376 KB
testcase_04 AC 389 ms
4,380 KB
testcase_05 AC 383 ms
4,384 KB
testcase_06 AC 371 ms
4,380 KB
testcase_07 AC 371 ms
4,380 KB
testcase_08 AC 319 ms
4,376 KB
testcase_09 AC 331 ms
4,376 KB
testcase_10 AC 201 ms
4,384 KB
testcase_11 AC 222 ms
4,380 KB
testcase_12 AC 185 ms
4,376 KB
testcase_13 AC 309 ms
4,380 KB
testcase_14 AC 343 ms
4,380 KB
testcase_15 AC 144 ms
4,376 KB
testcase_16 AC 215 ms
4,380 KB
testcase_17 AC 242 ms
4,376 KB
testcase_18 AC 367 ms
4,376 KB
testcase_19 AC 283 ms
4,380 KB
testcase_20 AC 239 ms
4,444 KB
testcase_21 AC 230 ms
4,380 KB
testcase_22 AC 228 ms
4,380 KB
testcase_23 AC 208 ms
4,380 KB
testcase_24 AC 41 ms
4,448 KB
testcase_25 AC 38 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; ll k;
    int p;
    cin>>n>>k>>p;
    int a[100010], b[100010];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<n; i++){
        cin>>b[i];
    }
    sort(a, a+n); sort(b, b+n);
    int l=-1, r=p-1;
    while(r-l>1){
        int m=(l+r)/2;
        ll c=0;
        for(int i=0; i<n; i++){
            int t=lower_bound(b, b+n, m+1-a[i])-b;
            c+=t;
            int t2=lower_bound(b, b+n, p-a[i])-b;
            int t3=lower_bound(b, b+n, m+p+1-a[i])-b;
            c+=t3-t2;
        }
        if(c>=k) r=m;
        else l=m;
    }
    cout<<r<<endl;
    return 0;
}
0