結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー vkgainzvkgainz
提出日時 2021-06-12 10:11:52
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,682 bytes
コンパイル時間 7,669 ms
コンパイル使用メモリ 136,164 KB
実行使用メモリ 26,392 KB
最終ジャッジ日時 2023-08-22 07:16:36
合計ジャッジ時間 13,059 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,768 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 6 ms
4,384 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 10 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 12 ms
4,384 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 199 ms
5,964 KB
testcase_19 AC 65 ms
4,388 KB
testcase_20 AC 209 ms
5,720 KB
testcase_21 AC 38 ms
4,924 KB
testcase_22 AC 76 ms
4,864 KB
testcase_23 AC 132 ms
5,692 KB
testcase_24 AC 111 ms
5,768 KB
testcase_25 AC 146 ms
5,560 KB
testcase_26 AC 196 ms
5,852 KB
testcase_27 AC 114 ms
4,868 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
権限があれば一括ダウンロードができます

ソースコード

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);
    map<long long, int> fl, fr;
    for(int i = 0; i < K; i++)
        for(int j = 0; j < L; j++)
            ++fl[A[i] * B[j]];
    for(int i = 0; i < M; i++)
        for(int j = 0; j < N; j++)
            ++fr[C[i] * D[j]];
    int sum = 0;
    for(auto [a, b] : fr) {
        sum += b;
        fr[a] = sum;
    }
    long long T;
    long long lo = -1e18, hi = 1e18;
    for(int j = 0; j < 62; j++) {
        long long mid = get_floor(lo, hi);
        long long num = 0LL;
        for(int x = 0; x < K; x++) {
            for(int y = 0; y < L; y++) {
                int a = A[x] * B[y];
                if(a > 0) {
                    long long look = mid / a;
                    if(mid < 0) look = (mid - a + 1) / a;
                    auto it = fr.upper_bound(look);
                    if(it == fr.begin()) continue;
                    --it;
                    num += it->second;
                }
                else if(a < 0) {
                    long long look;
                    if(mid > 0) look = - (mid / (- a));
                    else look = (-mid - a - 1) / (-a);
                    auto it = fr.lower_bound(look);
                    num += sum;
                    if(it == fr.begin()) continue;
                    --it;
                    num -= it->second;
                }
                else {
                   if(mid >= 0) num += sum;
                }
            }
        }
        if(num < S) lo = mid + 1;
        else hi = mid;
    }
    T = lo;
    long long left = 0LL, right = 0LL;
    pair<int, int> x, y;
    for(auto [a, b] : fl) {
        if(T % a == 0 && fr.find(T / a) != fr.end())
            left = a, right = T / a;
    }
    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