結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 NachiaNachia
提出日時 2021-01-22 22:33:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,990 bytes
コンパイル時間 3,476 ms
コンパイル使用メモリ 207,680 KB
実行使用メモリ 24,676 KB
最終ジャッジ日時 2023-08-27 20:28:03
合計ジャッジ時間 16,998 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
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,924 KB
testcase_64 AC 98 ms
21,400 KB
testcase_65 AC 99 ms
23,576 KB
testcase_66 AC 100 ms
23,136 KB
testcase_67 AC 100 ms
23,216 KB
testcase_68 AC 2 ms
4,376 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 2 ms
4,376 KB
testcase_71 AC 2 ms
4,384 KB
testcase_72 AC 2 ms
4,384 KB
testcase_73 AC 2 ms
4,376 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=Y.size(), k=Y.size();
    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=min(ans,constructans(i,j-1));
      }
      else if(X[i].first>0){
        while((k>0)?X[i].first*Y[k-1].first>x:false) k--;
        cnt+=k;
        if(k<Y.size()) ans=min(ans,constructans(i,k));
      }
      else{
        cnt+=Y.size();
      }
    }
  }
  else{
    int j=0, k=0;
    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>0) ans=min(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=min(ans,constructans(i,k));
      }
      else{
        ans=min(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; ans=res.second; } else{ r=m; }
  }
  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