結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-01-23 02:07:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,843 ms / 2,000 ms
コード長 2,976 bytes
コンパイル時間 1,206 ms
コンパイル使用メモリ 116,440 KB
実行使用メモリ 56,280 KB
最終ジャッジ日時 2023-08-28 12:24:51
合計ジャッジ時間 43,037 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 3 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,376 KB
testcase_18 AC 72 ms
5,644 KB
testcase_19 AC 28 ms
4,380 KB
testcase_20 AC 79 ms
5,508 KB
testcase_21 AC 21 ms
4,648 KB
testcase_22 AC 37 ms
4,684 KB
testcase_23 AC 55 ms
5,820 KB
testcase_24 AC 49 ms
5,520 KB
testcase_25 AC 53 ms
5,728 KB
testcase_26 AC 63 ms
5,692 KB
testcase_27 AC 42 ms
4,632 KB
testcase_28 AC 522 ms
22,164 KB
testcase_29 AC 467 ms
18,440 KB
testcase_30 AC 439 ms
15,992 KB
testcase_31 AC 611 ms
25,156 KB
testcase_32 AC 512 ms
30,012 KB
testcase_33 AC 409 ms
17,328 KB
testcase_34 AC 616 ms
28,628 KB
testcase_35 AC 795 ms
26,500 KB
testcase_36 AC 1,114 ms
39,624 KB
testcase_37 AC 213 ms
14,932 KB
testcase_38 AC 610 ms
20,552 KB
testcase_39 AC 349 ms
14,620 KB
testcase_40 AC 418 ms
18,704 KB
testcase_41 AC 604 ms
24,896 KB
testcase_42 AC 1,199 ms
36,064 KB
testcase_43 AC 574 ms
21,688 KB
testcase_44 AC 828 ms
27,676 KB
testcase_45 AC 704 ms
23,840 KB
testcase_46 AC 607 ms
31,956 KB
testcase_47 AC 314 ms
15,592 KB
testcase_48 AC 1,469 ms
56,176 KB
testcase_49 AC 1,327 ms
56,100 KB
testcase_50 AC 1,590 ms
55,728 KB
testcase_51 AC 1,469 ms
55,932 KB
testcase_52 AC 1,319 ms
56,044 KB
testcase_53 AC 1,792 ms
55,804 KB
testcase_54 AC 1,764 ms
56,064 KB
testcase_55 AC 1,843 ms
55,904 KB
testcase_56 AC 1,771 ms
56,280 KB
testcase_57 AC 1,396 ms
55,960 KB
testcase_58 AC 763 ms
12,368 KB
testcase_59 AC 771 ms
12,180 KB
testcase_60 AC 762 ms
12,188 KB
testcase_61 AC 759 ms
12,444 KB
testcase_62 AC 763 ms
12,504 KB
testcase_63 AC 45 ms
12,432 KB
testcase_64 AC 45 ms
12,440 KB
testcase_65 AC 44 ms
12,404 KB
testcase_66 AC 45 ms
12,684 KB
testcase_67 AC 46 ms
13,932 KB
testcase_68 AC 1 ms
4,380 KB
testcase_69 AC 1 ms
4,380 KB
testcase_70 AC 2 ms
4,376 KB
testcase_71 AC 1 ms
4,376 KB
testcase_72 AC 2 ms
4,380 KB
testcase_73 AC 2 ms
4,376 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;
    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[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