結果

問題 No.1597 Matrix Sort
ユーザー chocoruskchocorusk
提出日時 2021-07-09 21:35:19
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 354 ms / 1,500 ms
コード長 1,224 bytes
コンパイル時間 2,929 ms
使用メモリ 4,352 KB
最終ジャッジ日時 2023-02-01 22:19:55
合計ジャッジ時間 9,967 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
3,504 KB
testcase_01 AC 1 ms
3,480 KB
testcase_02 AC 1 ms
3,432 KB
testcase_03 AC 331 ms
4,324 KB
testcase_04 AC 353 ms
4,252 KB
testcase_05 AC 354 ms
4,272 KB
testcase_06 AC 342 ms
4,200 KB
testcase_07 AC 343 ms
4,328 KB
testcase_08 AC 296 ms
4,192 KB
testcase_09 AC 305 ms
4,276 KB
testcase_10 AC 196 ms
4,340 KB
testcase_11 AC 177 ms
4,348 KB
testcase_12 AC 152 ms
4,196 KB
testcase_13 AC 277 ms
4,200 KB
testcase_14 AC 311 ms
4,188 KB
testcase_15 AC 124 ms
4,220 KB
testcase_16 AC 184 ms
4,192 KB
testcase_17 AC 210 ms
4,268 KB
testcase_18 AC 338 ms
4,300 KB
testcase_19 AC 242 ms
4,264 KB
testcase_20 AC 202 ms
4,192 KB
testcase_21 AC 195 ms
4,336 KB
testcase_22 AC 197 ms
4,352 KB
testcase_23 AC 185 ms
4,248 KB
testcase_24 AC 39 ms
4,184 KB
testcase_25 AC 36 ms
4,196 KB
testcase_26 AC 1 ms
3,564 KB
testcase_27 AC 1 ms
3,532 KB
testcase_28 AC 1 ms
3,428 KB
testcase_29 AC 1 ms
3,528 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