結果

問題 No.1597 Matrix Sort
ユーザー hiikunZhiikunZ
提出日時 2021-07-09 22:14:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,287 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 207,652 KB
実行使用メモリ 5,612 KB
最終ジャッジ日時 2023-09-14 09:26:26
合計ジャッジ時間 10,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 404 ms
5,484 KB
testcase_04 AC 405 ms
5,428 KB
testcase_05 AC 426 ms
5,476 KB
testcase_06 AC 426 ms
5,316 KB
testcase_07 WA -
testcase_08 AC 353 ms
5,312 KB
testcase_09 AC 358 ms
5,412 KB
testcase_10 AC 264 ms
5,412 KB
testcase_11 AC 239 ms
5,472 KB
testcase_12 AC 184 ms
5,432 KB
testcase_13 AC 332 ms
5,612 KB
testcase_14 AC 375 ms
5,328 KB
testcase_15 AC 168 ms
5,332 KB
testcase_16 AC 236 ms
5,544 KB
testcase_17 AC 271 ms
5,256 KB
testcase_18 AC 401 ms
5,468 KB
testcase_19 AC 317 ms
5,480 KB
testcase_20 AC 263 ms
5,480 KB
testcase_21 AC 256 ms
5,488 KB
testcase_22 AC 260 ms
5,256 KB
testcase_23 AC 247 ms
5,412 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const ll MAX = 5000000000000000000;
const ld PI = 3.14159265358979;
const ll MOD = 1000000007;//2024948111;
random_device rd;
mt19937 mt(rd());
ld dotorad(ld K){return PI * K / 180.0;}
ld radtodo(ld K){return K * 180.0 / PI;}
int main(){
    ll N,K,P;
    cin >> N >> K >> P;
    vector<ll> A(N),B(N);
    for(ll i = 0;i < N;i++) cin >> A[i];
    for(ll i = 0;i < N;i++) cin >> B[i];
    sort(A.begin(),A.end());
    B.emplace_back(-MAX);
    B.emplace_back(MAX);
    sort(B.begin(),B.end());
    ll l = P - 1,r = -1;
    while(l - r > 1){
        ll m = (l + r) / 2,c = 0;
        for(ll i = 0;i < N;i++){
            ll a,b;
            a = (P - 1) - A[i];
            b = m - A[i];
            ll p = N - (upper_bound(B.begin(),B.end(),a) - B.begin());
            ll q = N - (lower_bound(B.begin(),B.end(),b) - B.begin());
            a = 2 * P - 1 - A[i];
            b = P + m - A[i];
            p += N - (upper_bound(B.begin(),B.end(),a) - B.begin());
            q += N - (lower_bound(B.begin(),B.end(),b) - B.begin());
            c += q - p;
        }
        //cout << m << "/" << c << endl;
        if(c < N * N - K + 1) l = m;
        else r = m;
    }
    cout << r << endl;
}
0