結果
問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
ユーザー | SSRS |
提出日時 | 2021-01-22 22:41:54 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 3,326 bytes |
コンパイル時間 | 1,998 ms |
コンパイル使用メモリ | 179,168 KB |
実行使用メモリ | 13,276 KB |
最終ジャッジ日時 | 2024-06-08 16:26:09 |
合計ジャッジ時間 | 17,637 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | RE | - |
testcase_46 | RE | - |
testcase_47 | RE | - |
testcase_48 | AC | 184 ms
13,144 KB |
testcase_49 | AC | 144 ms
13,272 KB |
testcase_50 | AC | 205 ms
13,272 KB |
testcase_51 | AC | 189 ms
13,148 KB |
testcase_52 | AC | 128 ms
13,276 KB |
testcase_53 | RE | - |
testcase_54 | RE | - |
testcase_55 | RE | - |
testcase_56 | RE | - |
testcase_57 | RE | - |
testcase_58 | AC | 85 ms
12,128 KB |
testcase_59 | AC | 92 ms
12,124 KB |
testcase_60 | AC | 89 ms
12,128 KB |
testcase_61 | AC | 90 ms
12,256 KB |
testcase_62 | AC | 88 ms
12,128 KB |
testcase_63 | AC | 12 ms
8,804 KB |
testcase_64 | AC | 14 ms
8,832 KB |
testcase_65 | AC | 13 ms
8,960 KB |
testcase_66 | AC | 13 ms
8,832 KB |
testcase_67 | AC | 13 ms
9,088 KB |
testcase_68 | AC | 2 ms
5,376 KB |
testcase_69 | AC | 2 ms
5,376 KB |
testcase_70 | AC | 2 ms
5,376 KB |
testcase_71 | AC | 2 ms
5,376 KB |
testcase_72 | AC | 2 ms
5,376 KB |
testcase_73 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000000000000; int main(){ int K, L, M, N; long long S; cin >> K >> L >> M >> N >> S; vector<int> A(K); for (int i = 0; i < K; i++){ cin >> A[i]; } vector<int> B(L); for (int i = 0; i < L; i++){ cin >> B[i]; } vector<int> C(M); for (int i = 0; i < M; i++){ cin >> C[i]; } vector<int> D(N); for (int i = 0; i < N; i++){ cin >> D[i]; } vector<long long> X(K * L); for (int i = 0; i < K; i++){ for (int j = 0; j < L; j++){ X[i * L + j] = A[i] * B[j]; } } vector<long long> Y(M * N); for (int i = 0; i < M; i++){ for (int j = 0; j < N; j++){ Y[i * N + j] = C[i] * D[j]; } } sort(Y.begin(), Y.end()); vector<long long> pos, neg; long long zero = 0; for (int i = 0; i < K * L; i++){ if (X[i] > 0){ pos.push_back(X[i]); } if (X[i] < 0){ neg.push_back(X[i]); } if (X[i] == 0){ zero++; } } sort(pos.begin(), pos.end(), greater<long long>()); sort(neg.begin(), neg.end()); int pcnt = pos.size(); int ncnt = neg.size(); long long tv = -INF; long long fv = INF; while (fv - tv > 1){ long long mid = (tv + fv) / 2; long long cnt = 0; if (mid > 0){ cnt += zero * (N * M); } int pc = 0; for (int i = 0; i < pcnt; i++){ if (pc > 0){ assert(pos[i] * Y[pc - 1] < mid); } while (pc < N * M){ if (pos[i] * Y[pc] < mid){ pc++; } else { break; } } cnt += pc; } int nc = 0; for (int i = 0; i < ncnt; i++){ if (nc > 0){ assert(neg[i] * Y[nc - 1] >= mid); } while (nc < N * M){ if (neg[i] * Y[nc] >= mid){ nc++; } else { break; } } cnt += N * M - nc; } if (cnt < S){ tv = mid; } else { fv = mid; } } cout << tv << endl; for (int i = 0; i < K * L; i++){ int id = -1; if (X[i] >= 0){ int tv2 = -1; int fv2 = N * M; while (fv2 - tv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] <= tv){ tv2 = mid2; } else { fv2 = mid2; } } if (tv2 != -1){ if (X[i] * Y[tv2] == tv){ id = tv2; } } } else { int tv2 = N * M; int fv2 = -1; while (tv2 - fv2 > 1){ int mid2 = (tv2 + fv2) / 2; if (X[i] * Y[mid2] <= tv){ tv2 = mid2; } else { fv2 = mid2; } } if (tv2 != N * M){ if (X[i] * Y[tv2] == tv){ id = tv2; } } } if (id != -1){ bool ok1 = false; for (int j = 0; j < K; j++){ for (int k = 0; k < L; k++){ if (A[j] * B[k] == X[i]){ cout << A[j] << ' ' << B[k] << ' '; ok1 = true; break; } } if (ok1){ break; } } bool ok2 = false; for (int j = 0; j < M; j++){ for (int k = 0; k < N; k++){ if (C[j] * D[k] == Y[id]){ cout << C[j] << ' ' << D[k] << endl; ok2 = true; break; } } if (ok2){ break; } } break; } } }