結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-01-23 02:04:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,953 ms / 2,000 ms
コード長 2,942 bytes
コンパイル時間 1,262 ms
コンパイル使用メモリ 110,360 KB
実行使用メモリ 54,672 KB
最終ジャッジ日時 2023-08-28 12:21:32
合計ジャッジ時間 46,659 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 6 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 82 ms
6,048 KB
testcase_19 AC 31 ms
4,456 KB
testcase_20 AC 90 ms
5,920 KB
testcase_21 AC 25 ms
4,980 KB
testcase_22 AC 40 ms
4,808 KB
testcase_23 AC 62 ms
5,768 KB
testcase_24 AC 56 ms
5,704 KB
testcase_25 AC 59 ms
5,652 KB
testcase_26 AC 73 ms
6,072 KB
testcase_27 AC 47 ms
4,876 KB
testcase_28 AC 650 ms
24,224 KB
testcase_29 AC 547 ms
19,492 KB
testcase_30 AC 498 ms
17,020 KB
testcase_31 AC 693 ms
25,916 KB
testcase_32 AC 647 ms
31,844 KB
testcase_33 AC 469 ms
17,316 KB
testcase_34 AC 759 ms
30,540 KB
testcase_35 AC 900 ms
27,396 KB
testcase_36 AC 1,382 ms
42,232 KB
testcase_37 AC 254 ms
15,480 KB
testcase_38 AC 711 ms
21,280 KB
testcase_39 AC 385 ms
14,976 KB
testcase_40 AC 494 ms
19,356 KB
testcase_41 AC 718 ms
25,708 KB
testcase_42 AC 1,390 ms
36,576 KB
testcase_43 AC 698 ms
23,816 KB
testcase_44 AC 951 ms
29,052 KB
testcase_45 AC 814 ms
24,044 KB
testcase_46 AC 728 ms
33,048 KB
testcase_47 AC 378 ms
16,608 KB
testcase_48 AC 1,447 ms
53,756 KB
testcase_49 AC 1,301 ms
54,248 KB
testcase_50 AC 1,530 ms
53,756 KB
testcase_51 AC 1,433 ms
54,032 KB
testcase_52 AC 1,268 ms
54,672 KB
testcase_53 AC 1,783 ms
53,632 KB
testcase_54 AC 1,752 ms
53,572 KB
testcase_55 AC 1,953 ms
53,332 KB
testcase_56 AC 1,741 ms
53,492 KB
testcase_57 AC 1,380 ms
53,984 KB
testcase_58 AC 744 ms
12,396 KB
testcase_59 AC 742 ms
12,952 KB
testcase_60 AC 745 ms
12,776 KB
testcase_61 AC 745 ms
13,996 KB
testcase_62 AC 745 ms
13,836 KB
testcase_63 AC 38 ms
12,628 KB
testcase_64 AC 37 ms
14,016 KB
testcase_65 AC 37 ms
11,968 KB
testcase_66 AC 37 ms
12,516 KB
testcase_67 AC 37 ms
12,792 KB
testcase_68 AC 1 ms
4,380 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 2 ms
4,376 KB
testcase_71 AC 2 ms
4,380 KB
testcase_72 AC 2 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>
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;
    cin>>n>>m>>p>>q>>r;
    vector<LL> v1,v2;
    vector<LL> va(n),vb(m),vc(p),vd(q);
    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[3]={-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();
                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+=distance(v2.begin(),itr);
            }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+=distance(itr,v2.end());
            }
        }
        if(a<r)z[0]=z[2];
        else z[1]=z[2];
    }
    cout<<z[1]<<endl;
    for(auto node:m1){
        auto itr=m2.begin();
        if(node.first==0){
            if(z[1])continue;
        }else{
            if(abs(z[1])%node.first)continue;
            a=z[1]/node.first;
            itr=m2.find(a);
            if(itr==m2.end())continue;
        }
        cout<<node.second.first<<" "<<node.second.second<<" ";
        cout<<itr->second.first<<" "<<itr->second.second<<endl;
        return 0;
    }
}
0