結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-01-23 01:59:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,780 bytes
コンパイル時間 1,141 ms
コンパイル使用メモリ 110,908 KB
実行使用メモリ 55,496 KB
最終ジャッジ日時 2023-08-28 12:02:04
合計ジャッジ時間 45,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 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,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 2 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,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 77 ms
6,008 KB
testcase_19 AC 29 ms
4,420 KB
testcase_20 AC 82 ms
5,676 KB
testcase_21 AC 24 ms
4,844 KB
testcase_22 AC 38 ms
4,744 KB
testcase_23 AC 59 ms
5,708 KB
testcase_24 AC 51 ms
5,968 KB
testcase_25 AC 55 ms
5,772 KB
testcase_26 AC 69 ms
5,828 KB
testcase_27 AC 43 ms
4,820 KB
testcase_28 RE -
testcase_29 AC 508 ms
19,280 KB
testcase_30 AC 464 ms
17,064 KB
testcase_31 AC 659 ms
25,880 KB
testcase_32 AC 612 ms
32,120 KB
testcase_33 AC 442 ms
17,540 KB
testcase_34 AC 711 ms
30,688 KB
testcase_35 AC 837 ms
27,328 KB
testcase_36 AC 1,253 ms
42,400 KB
testcase_37 AC 242 ms
15,416 KB
testcase_38 AC 668 ms
21,448 KB
testcase_39 AC 371 ms
14,848 KB
testcase_40 AC 461 ms
19,376 KB
testcase_41 AC 662 ms
25,836 KB
testcase_42 AC 1,310 ms
36,604 KB
testcase_43 AC 640 ms
23,784 KB
testcase_44 AC 911 ms
29,076 KB
testcase_45 AC 752 ms
24,272 KB
testcase_46 AC 713 ms
32,908 KB
testcase_47 AC 349 ms
16,416 KB
testcase_48 AC 1,342 ms
53,776 KB
testcase_49 AC 1,248 ms
54,372 KB
testcase_50 AC 1,419 ms
53,756 KB
testcase_51 AC 1,367 ms
53,828 KB
testcase_52 AC 1,183 ms
53,916 KB
testcase_53 AC 1,649 ms
53,852 KB
testcase_54 AC 1,618 ms
55,496 KB
testcase_55 AC 1,733 ms
53,288 KB
testcase_56 AC 1,614 ms
54,112 KB
testcase_57 AC 1,295 ms
53,604 KB
testcase_58 AC 752 ms
13,088 KB
testcase_59 AC 727 ms
11,844 KB
testcase_60 AC 716 ms
14,564 KB
testcase_61 AC 714 ms
12,764 KB
testcase_62 AC 719 ms
14,880 KB
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 AC 2 ms
4,376 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 RE -
権限があれば一括ダウンロードができます

ソースコード

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<int,int> 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,LL> 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]]=va[i];
        }
    }
    for(i=0;i<p;i++){
        for(j=0;j<q;j++){
            v2.push_back(vc[i]*vd[j]);
            m2[vc[i]*vd[j]]=vc[i];
        }
    }
    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){
        if(z[1]%node.first)continue;
        a=z[1]/node.first;
        auto itr=m2.find(a);
        if(itr==m2.end())continue;
        cout<<node.second<<" "<<node.first/node.second<<" ";
        cout<<itr->second<<" "<<itr->first/itr->second<<endl;
        return 0;
    }
}
0