結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー vkgainzvkgainz
提出日時 2021-06-12 10:33:02
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,468 bytes
コンパイル時間 12,781 ms
コンパイル使用メモリ 134,072 KB
実行使用メモリ 8,976 KB
最終ジャッジ日時 2023-08-22 07:38:58
合計ジャッジ時間 21,714 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 91 ms
8,636 KB
testcase_59 AC 92 ms
8,720 KB
testcase_60 AC 90 ms
8,728 KB
testcase_61 AC 90 ms
8,720 KB
testcase_62 AC 89 ms
8,724 KB
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 AC 1 ms
4,500 KB
testcase_71 AC 2 ms
4,376 KB
testcase_72 AC 1 ms
4,500 KB
testcase_73 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

void read(vector<int> &v, int sz) {
    for(int i = 0; i < sz; i++) {
        cin >> v[i];
    }
}

long long get_floor(long long lo, long long hi) {
    long long x = (lo + hi);
    if(abs(x) % 2 == 0) return x / 2;
    if(x > 0) return x / 2;
    return (x - 1) / 2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int K, L, M, N;
    long long S;
    cin >> K >> L >> M >> N >> S;
    vector<int> A(K), B(L), C(M), D(N);
    read(A, K);
    read(B, L);
    read(C, M);
    read(D, N);
    vector<int> fl, fr;
    for(int i = 0; i < K; i++)
        for(int j = 0; j < L; j++)
            fl.push_back(A[i] * B[j]);
    sort(fl.begin(), fl.end());
    for(int i = 0; i < M; i++)
        for(int j = 0; j < N; j++)
            fr.push_back(C[i] * D[j]);
    sort(fr.begin(), fr.end());
    vector<int> pos, neg;
    int zer = 0;
    for(int i = 0; i < K; i++)
        for(int j = 0; j < L; j++) {
            if(A[i] * B[j] > 0) pos.push_back(A[i] * B[j]);
            else if(A[i] * B[j] < 0) neg.push_back(A[i] * B[j]);
            else ++zer;
        }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());
    long long T;
    long long lo = -1e18, hi = 1e18;
    for(int x = 0; x < 62; x++) {
        long long mid = get_floor(lo, hi);
        long long num = 0LL;
        int j = 0;
        for(int i = 0; i < (int) pos.size(); i++) {
            while(j < M * N && pos[i] * 1LL * fr[j] <= mid)
                ++j;
            num += j;
        }
        j = 0;
        for(int i = (int) neg.size() - 1; i >= 0; i--) {
            while(j < M * N && neg[i] * 1LL * fr[j] > mid)
                ++j;
            num += M * N - j;
        }
        if(mid >= 0) num += zer * 1LL * M * N;
        if(num < S) lo = mid + 1;
        else hi = mid;
    }
    T = lo;
    long long left = 0LL, right = 0LL;
    for(int i = 0; i < K * L; i++)
        if(T % fl[i] == 0)
            left = fl[i], right = T / fl[i];
    pair<int, int> x, y;
    for(int i = 0; i < K; i++) {
        for(int j = 0; j < L; j++) {
            if(A[i] * 1LL * B[j] == left)
                x = {A[i], B[j]};
        }
    }
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < N; j++) {
            if(C[i] * 1LL * D[j] == right)
                y = {C[i], D[j]};
        }
    }
    cout << T << "\n";
    cout << x.first << " " << x.second << " " << y.first << " " << y.second << "\n";
}
0