結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 NachiaNachia
提出日時 2021-01-22 22:06:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,028 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 209,844 KB
実行使用メモリ 24,472 KB
最終ジャッジ日時 2023-08-27 19:18:45
合計ジャッジ時間 16,458 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
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 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 101 ms
23,584 KB
testcase_64 AC 99 ms
21,820 KB
testcase_65 AC 100 ms
23,124 KB
testcase_66 AC 100 ms
22,424 KB
testcase_67 AC 100 ms
23,496 KB
testcase_68 AC 1 ms
4,380 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 1 ms
4,376 KB
testcase_71 AC 1 ms
4,500 KB
testcase_72 AC 2 ms
4,376 KB
testcase_73 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int N[4];
LL S;
int A[4][600];
vector<pair<LL,int>> X;
vector<pair<LL,int>> Y;

const LL INF=1ll<<40;

pair<LL,pair<int,int>> constructans(int xp,int yp){
  return {X[xp].first*Y[yp].first,{X[xp].second,Y[yp].second}};
}

// x 以下を数える
pair<LL,pair<int,int>> search(LL x){
  LL cnt=0;
  pair<LL,pair<int,int>> ans={-INF,{-1,-1}};
  if(x>=0){
    int j=0, k=Y.size();
    rep(i,X.size()){
      if(X[i].first<0){
        while((j<Y.size())?X[i].first*Y[j].first>x:false) j++;
        cnt+=Y.size()-j;
        if(j<Y.size()) ans=max(ans,constructans(i,j));
      }
      else if(X[i].first>0){
        while((k>0)?X[i].first*Y[k-1].first>x:false) k--;
        cnt+=k;
        if(k>0) ans=max(ans,constructans(i,k-1));
      }
      else{
        cnt+=Y.size();
        ans=max(ans,constructans(i,0));
      }
    }
  }
  else{
    int j=Y.size(), k=0;
    rep(i,X.size()){
      if(X[i].first<0){
        while((j>0)?X[i].first*Y[j-1].first<=x:false) j--;
        cnt+=Y.size()-j;
        if(j>0) ans=max(ans,constructans(i,j-1));
      }
      else if(X[i].first>0){
        while((k<Y.size())?X[i].first*Y[k].first<=x:false) k++;
        cnt+=k;
        if(k<Y.size()) ans=max(ans,constructans(i,k));
      }
      else{
        ans=max(ans,constructans(i,0));
      }
    }
  }
  ans.first=cnt;
  return ans;
}

int main() {
  rep(i,4) cin>>N[i]; cin>>S;
  rep(i,4) rep(j,N[i]) cin>>A[i][j];
  rep(i,N[0]) rep(j,N[1]) X.push_back({A[0][i]*A[1][j],i*600+j}); sort(X.begin(),X.end());
  rep(i,N[2]) rep(j,N[3]) Y.push_back({A[2][i]*A[3][j],i*600+j}); sort(Y.begin(),Y.end());
  LL l=-INF, r=INF; pair<int,int> ans;
  while(r-l>1){
    LL m=(l+r)/2;
    auto res=search(m);
    if(res.first<S) l=m; else{ r=m; ans=res.second; }
  }
  cout<<r<<endl;
  cout<<A[0][ans.first/600]<<" "<<A[1][ans.first%600]<<" "<<A[2][ans.second/600]<<" "<<A[3][ans.second%600]<<endl;
  return 0;
}
0