結果

問題 No.1597 Matrix Sort
ユーザー hiikunZhiikunZ
提出日時 2021-07-09 23:23:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 422 ms / 1,500 ms
コード長 1,283 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 206,796 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-09-14 10:50:56
合計ジャッジ時間 10,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 397 ms
5,408 KB
testcase_04 AC 402 ms
5,432 KB
testcase_05 AC 418 ms
5,536 KB
testcase_06 AC 422 ms
5,416 KB
testcase_07 AC 417 ms
5,352 KB
testcase_08 AC 348 ms
5,416 KB
testcase_09 AC 352 ms
5,408 KB
testcase_10 AC 262 ms
5,352 KB
testcase_11 AC 243 ms
5,536 KB
testcase_12 AC 185 ms
5,472 KB
testcase_13 AC 331 ms
5,540 KB
testcase_14 AC 374 ms
5,488 KB
testcase_15 AC 168 ms
5,488 KB
testcase_16 AC 238 ms
5,428 KB
testcase_17 AC 273 ms
5,360 KB
testcase_18 AC 390 ms
5,484 KB
testcase_19 AC 315 ms
5,676 KB
testcase_20 AC 265 ms
5,416 KB
testcase_21 AC 257 ms
5,484 KB
testcase_22 AC 261 ms
5,488 KB
testcase_23 AC 251 ms
5,540 KB
testcase_24 AC 53 ms
5,352 KB
testcase_25 AC 51 ms
5,484 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 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,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