結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 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,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 11 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 199 ms
5,976 KB
testcase_19 AC 58 ms
4,380 KB
testcase_20 AC 202 ms
5,772 KB
testcase_21 AC 39 ms
4,924 KB
testcase_22 AC 77 ms
4,868 KB
testcase_23 AC 140 ms
5,688 KB
testcase_24 AC 111 ms
5,760 KB
testcase_25 AC 129 ms
5,524 KB
testcase_26 AC 175 ms
5,860 KB
testcase_27 AC 104 ms
4,852 KB
testcase_28 RE -
testcase_29 AC 2,465 ms
18,084 KB
testcase_30 AC 1,922 ms
15,952 KB
testcase_31 AC 2,607 ms
22,820 KB
testcase_32 AC 2,669 ms
29,092 KB
testcase_33 AC 1,815 ms
16,256 KB
testcase_34 AC 2,547 ms
27,784 KB
testcase_35 RE -
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(auto [a, b] : fl) {
            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 += b * 1LL * 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 += b * 1LL * sum;
                if(it == fr.begin()) continue;
                --it;
                num -= b * 1LL * it->second;
            }
            else {
                if(mid >= 0) num += b * 1LL * 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