結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー SSRSSSRS
提出日時 2021-01-22 22:27:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,270 bytes
コンパイル時間 3,494 ms
コンパイル使用メモリ 198,484 KB
実行使用メモリ 10,896 KB
最終ジャッジ日時 2023-08-27 20:13:20
合計ジャッジ時間 18,698 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 201 ms
10,816 KB
testcase_49 AC 128 ms
10,896 KB
testcase_50 AC 229 ms
10,752 KB
testcase_51 AC 190 ms
10,696 KB
testcase_52 AC 139 ms
10,696 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 66 ms
10,204 KB
testcase_59 AC 65 ms
10,392 KB
testcase_60 AC 60 ms
10,376 KB
testcase_61 AC 60 ms
10,332 KB
testcase_62 AC 60 ms
10,316 KB
testcase_63 AC 12 ms
8,920 KB
testcase_64 AC 12 ms
8,880 KB
testcase_65 AC 13 ms
8,900 KB
testcase_66 AC 13 ms
8,776 KB
testcase_67 AC 13 ms
8,848 KB
testcase_68 AC 2 ms
4,380 KB
testcase_69 AC 1 ms
4,380 KB
testcase_70 AC 1 ms
4,376 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 2 ms
4,380 KB
testcase_73 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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<int> pos, neg;
  int 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<int>());
  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 += (long long) zero * (N * M);
    }
    int pc = 0;
    for (int i = 0; i < pcnt; i++){
      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++){
      while (nc < N * M){
        if (pos[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;
    }
  }
}
0