結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-01-23 02:35:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,889 ms / 2,000 ms
コード長 3,114 bytes
コンパイル時間 2,031 ms
コンパイル使用メモリ 127,088 KB
実行使用メモリ 56,672 KB
最終ジャッジ日時 2023-08-28 12:55:50
合計ジャッジ時間 48,166 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 79 ms
5,808 KB
testcase_19 AC 30 ms
4,384 KB
testcase_20 AC 85 ms
5,472 KB
testcase_21 AC 24 ms
4,640 KB
testcase_22 AC 37 ms
4,684 KB
testcase_23 AC 59 ms
5,856 KB
testcase_24 AC 50 ms
5,556 KB
testcase_25 AC 55 ms
5,744 KB
testcase_26 AC 68 ms
5,476 KB
testcase_27 AC 44 ms
4,752 KB
testcase_28 AC 593 ms
22,104 KB
testcase_29 AC 500 ms
18,524 KB
testcase_30 AC 461 ms
16,052 KB
testcase_31 AC 661 ms
25,136 KB
testcase_32 AC 524 ms
29,584 KB
testcase_33 AC 430 ms
17,488 KB
testcase_34 AC 708 ms
28,280 KB
testcase_35 AC 879 ms
26,416 KB
testcase_36 AC 1,234 ms
40,408 KB
testcase_37 AC 226 ms
14,868 KB
testcase_38 AC 658 ms
20,436 KB
testcase_39 AC 376 ms
14,584 KB
testcase_40 AC 464 ms
18,496 KB
testcase_41 AC 654 ms
24,876 KB
testcase_42 AC 1,250 ms
37,472 KB
testcase_43 AC 616 ms
21,748 KB
testcase_44 AC 891 ms
27,600 KB
testcase_45 AC 742 ms
23,856 KB
testcase_46 AC 673 ms
31,880 KB
testcase_47 AC 334 ms
15,508 KB
testcase_48 AC 1,652 ms
56,096 KB
testcase_49 AC 1,496 ms
55,924 KB
testcase_50 AC 1,684 ms
56,148 KB
testcase_51 AC 1,614 ms
56,148 KB
testcase_52 AC 1,494 ms
56,272 KB
testcase_53 AC 1,849 ms
56,652 KB
testcase_54 AC 1,768 ms
55,948 KB
testcase_55 AC 1,889 ms
55,824 KB
testcase_56 AC 1,788 ms
56,672 KB
testcase_57 AC 1,481 ms
56,072 KB
testcase_58 AC 946 ms
12,052 KB
testcase_59 AC 945 ms
13,208 KB
testcase_60 AC 889 ms
12,920 KB
testcase_61 AC 887 ms
12,620 KB
testcase_62 AC 888 ms
14,852 KB
testcase_63 AC 75 ms
12,364 KB
testcase_64 AC 75 ms
12,748 KB
testcase_65 AC 76 ms
13,236 KB
testcase_66 AC 75 ms
12,080 KB
testcase_67 AC 77 ms
13,616 KB
testcase_68 AC 1 ms
4,376 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 1 ms
4,384 KB
testcase_71 AC 2 ms
4,380 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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