結果

問題 No.1597 Matrix Sort
ユーザー Ryushi-techRyushi-tech
提出日時 2021-07-24 08:54:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 465 ms / 1,500 ms
コード長 1,458 bytes
コンパイル時間 2,640 ms
コンパイル使用メモリ 206,040 KB
実行使用メモリ 4,668 KB
最終ジャッジ日時 2023-09-26 14:34:39
合計ジャッジ時間 11,360 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 437 ms
4,576 KB
testcase_04 AC 453 ms
4,640 KB
testcase_05 AC 464 ms
4,668 KB
testcase_06 AC 465 ms
4,528 KB
testcase_07 AC 446 ms
4,644 KB
testcase_08 AC 385 ms
4,528 KB
testcase_09 AC 374 ms
4,580 KB
testcase_10 AC 234 ms
4,532 KB
testcase_11 AC 180 ms
4,532 KB
testcase_12 AC 282 ms
4,584 KB
testcase_13 AC 390 ms
4,524 KB
testcase_14 AC 400 ms
4,644 KB
testcase_15 AC 224 ms
4,648 KB
testcase_16 AC 233 ms
4,652 KB
testcase_17 AC 236 ms
4,528 KB
testcase_18 AC 457 ms
4,644 KB
testcase_19 AC 301 ms
4,532 KB
testcase_20 AC 228 ms
4,508 KB
testcase_21 AC 217 ms
4,644 KB
testcase_22 AC 216 ms
4,532 KB
testcase_23 AC 209 ms
4,580 KB
testcase_24 AC 235 ms
4,660 KB
testcase_25 AC 236 ms
4,592 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define cnts(x,c) count(all(x),c)
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) {a = b; return 1;} return 0;}
template<class T> void print(const T &t) {cout<<t<<"\n";}
template<class T> void PRINT(const T &t) {rep(i,sz(t)) cout<<t[i]<<" \n"[i==sz(t)-1];}
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

int n;
ll k,p;
vl a,b;

ll check(ll x){
    ll cnt=0;
    fore(y,a){
        cnt+=lower_bound(all(b),x-y)-b.begin();
        cnt+=lower_bound(all(b),x+p-y)-lower_bound(all(b),p-y);
    }
    return cnt;
}

int main() {
    fio(); cin>>n>>k>>p;
    a=b=vl(n);
    fore(x,a) cin>>x;
    fore(x,b) cin>>x;
    sort(all(a));sort(all(b));
    ll ng=0,ok=10010010010;
    while(ok-ng>1LL){
        ll mid=(ok+ng)/2;
        if(check(mid)>=k) ok=mid;
        else ng=mid;
    }
    print(ng);
}
0