結果

問題 No.1597 Matrix Sort
ユーザー Ryushi-techRyushi-tech
提出日時 2021-07-24 09:02:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 371 ms / 1,500 ms
コード長 1,455 bytes
コンパイル時間 2,592 ms
コンパイル使用メモリ 205,404 KB
実行使用メモリ 4,760 KB
最終ジャッジ日時 2023-09-26 14:43:20
合計ジャッジ時間 10,015 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 333 ms
4,676 KB
testcase_04 AC 347 ms
4,540 KB
testcase_05 AC 371 ms
4,668 KB
testcase_06 AC 357 ms
4,556 KB
testcase_07 AC 339 ms
4,560 KB
testcase_08 AC 265 ms
4,604 KB
testcase_09 AC 270 ms
4,648 KB
testcase_10 AC 173 ms
4,660 KB
testcase_11 AC 125 ms
4,644 KB
testcase_12 AC 201 ms
4,576 KB
testcase_13 AC 300 ms
4,628 KB
testcase_14 AC 307 ms
4,616 KB
testcase_15 AC 164 ms
4,620 KB
testcase_16 AC 175 ms
4,612 KB
testcase_17 AC 180 ms
4,632 KB
testcase_18 AC 341 ms
4,668 KB
testcase_19 AC 227 ms
4,644 KB
testcase_20 AC 170 ms
4,560 KB
testcase_21 AC 161 ms
4,640 KB
testcase_22 AC 152 ms
4,640 KB
testcase_23 AC 153 ms
4,680 KB
testcase_24 AC 166 ms
4,756 KB
testcase_25 AC 165 ms
4,760 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,388 KB
testcase_28 AC 1 ms
4,384 KB
testcase_29 AC 2 ms
4,384 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=10010010;
    while(ok-ng>1LL){
        ll mid=(ok+ng)/2;
        if(check(mid)>=k) ok=mid;
        else ng=mid;
    }
    print(ng);
}
0