結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-01-23 02:32:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,926 ms / 2,000 ms
コード長 3,022 bytes
コンパイル時間 1,367 ms
コンパイル使用メモリ 117,488 KB
実行使用メモリ 57,084 KB
最終ジャッジ日時 2023-08-28 12:52:48
合計ジャッジ時間 43,162 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 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,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 78 ms
5,756 KB
testcase_19 AC 30 ms
4,472 KB
testcase_20 AC 83 ms
5,564 KB
testcase_21 AC 22 ms
4,632 KB
testcase_22 AC 39 ms
4,584 KB
testcase_23 AC 58 ms
5,680 KB
testcase_24 AC 54 ms
5,440 KB
testcase_25 AC 55 ms
5,740 KB
testcase_26 AC 67 ms
5,868 KB
testcase_27 AC 45 ms
4,744 KB
testcase_28 AC 568 ms
22,152 KB
testcase_29 AC 508 ms
18,576 KB
testcase_30 AC 456 ms
16,164 KB
testcase_31 AC 620 ms
25,148 KB
testcase_32 AC 494 ms
31,004 KB
testcase_33 AC 418 ms
17,384 KB
testcase_34 AC 626 ms
28,648 KB
testcase_35 AC 826 ms
26,768 KB
testcase_36 AC 1,139 ms
40,220 KB
testcase_37 AC 223 ms
14,744 KB
testcase_38 AC 648 ms
20,396 KB
testcase_39 AC 366 ms
14,416 KB
testcase_40 AC 453 ms
18,424 KB
testcase_41 AC 629 ms
25,044 KB
testcase_42 AC 1,183 ms
35,508 KB
testcase_43 AC 614 ms
21,812 KB
testcase_44 AC 855 ms
27,672 KB
testcase_45 AC 743 ms
23,708 KB
testcase_46 AC 594 ms
31,884 KB
testcase_47 AC 340 ms
15,600 KB
testcase_48 AC 1,388 ms
56,132 KB
testcase_49 AC 1,334 ms
55,864 KB
testcase_50 AC 1,486 ms
55,924 KB
testcase_51 AC 1,474 ms
56,052 KB
testcase_52 AC 1,225 ms
55,864 KB
testcase_53 AC 1,784 ms
56,152 KB
testcase_54 AC 1,720 ms
57,080 KB
testcase_55 AC 1,926 ms
57,084 KB
testcase_56 AC 1,755 ms
56,936 KB
testcase_57 AC 1,458 ms
56,176 KB
testcase_58 AC 861 ms
12,448 KB
testcase_59 AC 865 ms
14,696 KB
testcase_60 AC 827 ms
12,252 KB
testcase_61 AC 828 ms
12,432 KB
testcase_62 AC 825 ms
12,708 KB
testcase_63 AC 64 ms
12,376 KB
testcase_64 AC 64 ms
12,436 KB
testcase_65 AC 65 ms
12,644 KB
testcase_66 AC 66 ms
13,024 KB
testcase_67 AC 65 ms
13,532 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 1 ms
4,376 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
using namespace std;
typedef long long int LL;
typedef pair<LL,LL> P;
typedef pair<LL,int> LP;
const LL INF=1LL<<60;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
    LL n,m,p,q,r;
    int i,j,k;
    LL a,b,c,d;
    cin>>n>>m>>p>>q>>r;
    vector<LL> v1,v2;
    vector<LL> va(n),vb(m),vc(p),vd(q);
    unordered_map<LL,P> m1,m2;
    for(i=0;i<n;i++)cin>>va[i];
    for(i=0;i<m;i++)cin>>vb[i];
    for(i=0;i<p;i++)cin>>vc[i];
    for(i=0;i<q;i++)cin>>vd[i];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            v1.push_back(va[i]*vb[j]);
            m1[va[i]*vb[j]]=make_pair(va[i],vb[j]);
        }
    }
    for(i=0;i<p;i++){
        for(j=0;j<q;j++){
            v2.push_back(vc[i]*vd[j]);
            m2[vc[i]*vd[j]]=make_pair(vc[i],vd[j]);
        }
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    LL z[5]={-INF,INF};
    while(z[1]-z[0]>1){
        z[2]=(z[0]+z[1])/2;
        a=0;
        for(i=0;i<v1.size();i++){
            if(v1[i]==0){
                if(z[2]>=0)a+=v2.size();
                if(z[2]==0)d=0;
                continue;
            }
            if(v1[i]>0){
                if(z[2]>=0)b=z[2]/v1[i];
                else b=-((-z[2]-1)/v1[i])-1;
                auto itr=upper_bound(v2.begin(),v2.end(),b);
                a+=itr-v2.begin();
                if(itr!=v2.begin()){
                    itr--;
                    if(z[2]==(*itr)*v1[i])d=v1[i];
                }
            }else{
                if(z[2]>=0)b=-(z[2]/(-v1[i]));
                else b=(-z[2]-1)/(-v1[i])+1;
                auto itr=lower_bound(v2.begin(),v2.end(),b);
                a+=v2.end()-itr;
                if((*itr)*v1[i]==z[2])d=v1[i];
            }
        }
        if(a<r)z[0]=z[2];
        else z[1]=z[2],z[5]=d;
    }
    cout<<z[1]<<endl;
    d=z[5];
    auto itr=m2.begin();
    if(d!=0){
        if(abs(z[1])%d)return 0;
        a=z[1]/d;
        itr=m2.find(a);
        if(itr==m2.end())return 0;
    }
    cout<<m1[d].first<<" "<<m1[d].second<<" ";
    cout<<itr->second.first<<" "<<itr->second.second<<endl;
}
0