結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー vkgainzvkgainz
提出日時 2021-06-12 09:46:49
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,427 bytes
コンパイル時間 15,458 ms
コンパイル使用メモリ 138,164 KB
実行使用メモリ 27,280 KB
最終ジャッジ日時 2023-08-22 06:18:24
合計ジャッジ時間 14,239 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 6 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 6 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 60 ms
4,380 KB
testcase_20 AC 203 ms
5,776 KB
testcase_21 WA -
testcase_22 AC 77 ms
4,948 KB
testcase_23 AC 138 ms
5,748 KB
testcase_24 AC 119 ms
5,796 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 101 ms
4,904 KB
testcase_28 RE -
testcase_29 AC 1,970 ms
18,176 KB
testcase_30 WA -
testcase_31 RE -
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];
    }
}

int main() {
    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 = -1e17, hi = 1e17;
    for(int j = 0; j < 60; j++) {
        long long mid = (lo + hi) / 2;
        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);
                //cout << mid << " " << look << "\n";
                auto it = fr.lower_bound(look);
                num += b * 1LL * sum;
                if(it == fr.begin()) continue;
                --it;
                //cout << mid << " " << it->first << " " << it->second << "\n";
                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, right;
    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