結果
問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
ユーザー | 👑 Kazun |
提出日時 | 2020-10-21 14:04:44 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,593 bytes |
コンパイル時間 | 1,236 ms |
コンパイル使用メモリ | 91,804 KB |
実行使用メモリ | 38,748 KB |
最終ジャッジ日時 | 2024-06-08 11:59:25 |
合計ジャッジ時間 | 12,288 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 3 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 3 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 14 ms
6,944 KB |
testcase_19 | AC | 8 ms
6,944 KB |
testcase_20 | AC | 16 ms
6,944 KB |
testcase_21 | AC | 8 ms
6,940 KB |
testcase_22 | AC | 11 ms
6,944 KB |
testcase_23 | AC | 14 ms
6,940 KB |
testcase_24 | AC | 16 ms
6,940 KB |
testcase_25 | AC | 15 ms
6,940 KB |
testcase_26 | AC | 17 ms
6,944 KB |
testcase_27 | AC | 10 ms
6,944 KB |
testcase_28 | AC | 129 ms
18,280 KB |
testcase_29 | AC | 105 ms
14,328 KB |
testcase_30 | AC | 82 ms
11,880 KB |
testcase_31 | AC | 95 ms
16,756 KB |
testcase_32 | AC | 143 ms
28,052 KB |
testcase_33 | AC | 78 ms
12,412 KB |
testcase_34 | AC | 148 ms
23,264 KB |
testcase_35 | AC | 152 ms
17,868 KB |
testcase_36 | AC | 237 ms
30,652 KB |
testcase_37 | AC | 60 ms
13,180 KB |
testcase_38 | AC | 113 ms
13,804 KB |
testcase_39 | AC | 65 ms
10,504 KB |
testcase_40 | AC | 93 ms
14,076 KB |
testcase_41 | AC | 148 ms
20,032 KB |
testcase_42 | AC | 189 ms
22,764 KB |
testcase_43 | AC | 141 ms
17,572 KB |
testcase_44 | AC | 152 ms
18,612 KB |
testcase_45 | AC | 119 ms
15,376 KB |
testcase_46 | AC | 116 ms
24,624 KB |
testcase_47 | AC | 79 ms
13,520 KB |
testcase_48 | AC | 238 ms
36,992 KB |
testcase_49 | AC | 185 ms
38,748 KB |
testcase_50 | AC | 254 ms
37,180 KB |
testcase_51 | AC | 226 ms
37,148 KB |
testcase_52 | AC | 188 ms
37,092 KB |
testcase_53 | AC | 307 ms
36,916 KB |
testcase_54 | AC | 287 ms
36,968 KB |
testcase_55 | AC | 343 ms
36,964 KB |
testcase_56 | AC | 294 ms
36,968 KB |
testcase_57 | AC | 196 ms
36,872 KB |
testcase_58 | AC | 85 ms
20,324 KB |
testcase_59 | AC | 85 ms
20,232 KB |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 14 ms
14,668 KB |
testcase_64 | AC | 14 ms
14,468 KB |
testcase_65 | AC | 15 ms
14,584 KB |
testcase_66 | AC | 14 ms
14,536 KB |
testcase_67 | AC | 14 ms
14,536 KB |
testcase_68 | AC | 2 ms
6,940 KB |
testcase_69 | AC | 2 ms
6,944 KB |
testcase_70 | AC | 2 ms
6,940 KB |
testcase_71 | AC | 2 ms
6,944 KB |
testcase_72 | AC | 2 ms
6,940 KB |
testcase_73 | AC | 2 ms
6,940 KB |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<set> using namespace std; using ll = long long; void input(vector<ll>& X) { for (int i = 0; i < X.size(); i++) { cin >> X.at(i); } } ll abs_max(vector<ll> X) { ll t = 0; for (int i = 0; i < X.size(); i++) { if (t < abs(X.at(i))) { t = abs(X.at(i)); } } return t; } pair<ll, ll> h(ll x, vector<ll> G, vector<ll> H) { if (x == 0) { if (find(G.begin(), G.end(), 0) != G.end()) { return make_pair(0, H[0]); } else { return make_pair(G[0], 0); } } set<ll> F(H.begin(), H.end()); for (auto g : G) { if (g == 0) continue; if (x % g == 0 && F.count(x / g)) { return make_pair(g, x / g); } } return make_pair(-1, -1); } int main() { ll K, L, M, N, S, T; cin >> K >> L >> M >> N >> S; vector<ll> A(K), B(L), C(M), D(N); vector<ll> U(K * L), V(M * N); vector<ll> U_pos(0), U_neg(0); vector<ll> V_pos(0), V_neg(0); ll U_positive, U_zero, U_negative; ll V_positive, V_zero, V_negative; ll E_positive, E_zero, E_negative; ll A_abs_max, B_abs_max, C_abs_max, D_abs_max; ll E_abs_max; input(A); input(B); input(C); input(D); A_abs_max = abs_max(A); B_abs_max = abs_max(B); C_abs_max = abs_max(C); D_abs_max = abs_max(D); E_abs_max = A_abs_max * B_abs_max * C_abs_max * D_abs_max; int t; t = 0; for (int w = 0; w < K; w++) { for (int x = 0; x < L; x++) { U.at(t++) = A.at(w) * B.at(x); } } t = 0; for (int y = 0; y < M; y++) { for (int z = 0; z < N; z++) { V.at(t++) = C.at(y) * D.at(z); } } sort(V.begin(), V.end()); for (auto u : U) { if (u > 0) { U_pos.push_back(u); } else if (u < 0) { U_neg.push_back(u); } } for (auto v : V) { if (v > 0) { V_pos.push_back(v); } else if (v < 0) { V_neg.push_back(v); } } sort(U_pos.begin(), U_pos.end()); sort(U_neg.begin(), U_neg.end()); sort(V_pos.begin(), V_pos.end()); sort(V_neg.begin(), V_neg.end()); U_positive = U_pos.size(); U_negative = U_neg.size(); U_zero = K * L - (U_positive + U_negative); V_positive = V_pos.size(); V_negative = V_neg.size(); V_zero = M * N - (V_positive + V_negative); E_positive = U_positive * V_positive + U_negative * V_negative; E_negative = U_positive * V_negative + U_negative * V_positive; E_zero = K * L * M * N - (E_positive + E_negative); ll Left, Right, Z, I; if (S <= E_negative) { Left = -E_abs_max; Right = 1; while (Right - Left > 1) { T = Left + (Right - Left) / 2; Z = I = 0; for (auto u : U_pos) { while (I < V_negative && u * V_neg.at(I) <= T) I++; Z += I; } I = 0; for (auto v : V_pos) { while (I < U_negative && v * U_neg.at(I) <= T) I++; Z += I; } if (Z >= S) { Right = T; } else { Left = T; } } T = Right; } else if (E_negative + 1 <= S && S <= E_negative + E_zero) { T = 0; } else { Left = 0; Right = E_abs_max + 1; while (Right - Left > 1) { T = Left + (Right - Left) / 2; Z = 0; I = V_positive; for (auto u : U_pos) { while (I>0 && u * V_pos.at(I-1) > T) I--; Z += I; } I = 0; for (auto v : V_neg) { while (I < U_negative && v * U_neg.at(U_negative-(I+1)) <= T) I++; Z += I; } if (Z >= S - (E_negative + E_zero)) { Right = T; } else { Left = T; } } T = Right; } ll alpha, beta, a, b, c, d; pair<ll, ll> P; P = h(T, U, V); alpha = P.first; beta = P.second; P = h(alpha, A, B); a = P.first; b = P.second; P = h(beta, C, D); c = P.first; d = P.second; cout << T << endl; cout << a << " " << b << " " << c << " " << d << endl; }