結果

問題 No.1460 Max of Min
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-04-01 00:02:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 2,855 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 110,772 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 05:02:29
合計ジャッジ時間 12,855 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
4,376 KB
testcase_01 AC 13 ms
4,380 KB
testcase_02 AC 19 ms
4,376 KB
testcase_03 AC 108 ms
4,376 KB
testcase_04 AC 100 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 103 ms
4,384 KB
testcase_07 AC 107 ms
4,380 KB
testcase_08 AC 25 ms
4,384 KB
testcase_09 AC 19 ms
4,380 KB
testcase_10 AC 96 ms
4,376 KB
testcase_11 AC 101 ms
4,376 KB
testcase_12 AC 54 ms
4,376 KB
testcase_13 AC 88 ms
4,376 KB
testcase_14 AC 62 ms
4,380 KB
testcase_15 AC 49 ms
4,380 KB
testcase_16 AC 93 ms
4,380 KB
testcase_17 AC 78 ms
4,376 KB
testcase_18 AC 34 ms
4,380 KB
testcase_19 AC 63 ms
4,380 KB
testcase_20 AC 41 ms
4,376 KB
testcase_21 AC 53 ms
4,380 KB
testcase_22 AC 67 ms
4,376 KB
testcase_23 AC 39 ms
4,376 KB
testcase_24 AC 79 ms
4,376 KB
testcase_25 AC 38 ms
4,376 KB
testcase_26 AC 94 ms
4,380 KB
testcase_27 AC 52 ms
4,376 KB
testcase_28 AC 43 ms
4,376 KB
testcase_29 AC 79 ms
4,380 KB
testcase_30 AC 99 ms
4,376 KB
testcase_31 AC 73 ms
4,376 KB
testcase_32 AC 85 ms
4,380 KB
testcase_33 AC 63 ms
4,380 KB
testcase_34 AC 73 ms
4,376 KB
testcase_35 AC 55 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 84 ms
4,380 KB
testcase_38 AC 100 ms
4,376 KB
testcase_39 AC 69 ms
4,380 KB
testcase_40 AC 61 ms
4,384 KB
testcase_41 AC 56 ms
4,380 KB
testcase_42 AC 48 ms
4,380 KB
testcase_43 AC 70 ms
4,380 KB
testcase_44 AC 79 ms
4,376 KB
testcase_45 AC 39 ms
4,380 KB
testcase_46 AC 68 ms
4,376 KB
testcase_47 AC 80 ms
4,380 KB
testcase_48 AC 92 ms
4,376 KB
testcase_49 AC 82 ms
4,380 KB
testcase_50 AC 42 ms
4,380 KB
testcase_51 AC 71 ms
4,380 KB
testcase_52 AC 51 ms
4,380 KB
testcase_53 AC 80 ms
4,376 KB
testcase_54 AC 97 ms
4,380 KB
testcase_55 AC 98 ms
4,376 KB
testcase_56 AC 97 ms
4,376 KB
testcase_57 AC 115 ms
4,376 KB
testcase_58 AC 102 ms
4,380 KB
testcase_59 AC 98 ms
4,380 KB
testcase_60 AC 103 ms
4,376 KB
testcase_61 AC 98 ms
4,376 KB
testcase_62 AC 94 ms
4,376 KB
testcase_63 AC 3 ms
4,380 KB
testcase_64 AC 3 ms
4,376 KB
testcase_65 AC 100 ms
4,376 KB
testcase_66 AC 100 ms
4,380 KB
testcase_67 AC 99 ms
4,376 KB
testcase_68 AC 102 ms
4,380 KB
testcase_69 AC 94 ms
4,376 KB
testcase_70 AC 104 ms
4,376 KB
testcase_71 AC 107 ms
4,380 KB
testcase_72 AC 97 ms
4,380 KB
testcase_73 AC 98 ms
4,376 KB
testcase_74 AC 100 ms
4,376 KB
testcase_75 AC 98 ms
4,380 KB
testcase_76 AC 92 ms
4,376 KB
testcase_77 AC 99 ms
4,376 KB
testcase_78 AC 102 ms
4,380 KB
testcase_79 AC 95 ms
4,380 KB
testcase_80 AC 106 ms
4,380 KB
testcase_81 AC 102 ms
4,380 KB
testcase_82 AC 98 ms
4,380 KB
testcase_83 AC 96 ms
4,376 KB
testcase_84 AC 91 ms
4,380 KB
testcase_85 AC 90 ms
4,376 KB
testcase_86 AC 98 ms
4,376 KB
testcase_87 AC 96 ms
4,380 KB
testcase_88 AC 95 ms
4,376 KB
testcase_89 AC 99 ms
4,380 KB
testcase_90 AC 99 ms
4,380 KB
testcase_91 AC 97 ms
4,380 KB
testcase_92 AC 96 ms
4,380 KB
testcase_93 AC 93 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘void sol::solve()’ 内:
main.cpp:99:28: 警告: narrowing conversion of ‘v1.std::vector<long long int>::size()’ from ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} to ‘LL’ {aka ‘long long int’} [-Wnarrowing]
   99 |         LL z[3]={-1,v1.size()};
      |                     ~~~~~~~^~

ソースコード

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>
#include<unordered_set>
#include<bitset>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;
const int INF=1<<30;
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'));
}

namespace sol{
    const LL N=1111;
    bitset<N> A,B;
    bitset<N*N*2> C;
    LL n,m;

    bool check(){
        LL i,j,k;
        LL a,b,c;
        LL mod=-1;
        C.reset();
        if(m<n)return A[m];
        for(i=0;i<n;i++){
            if(B[i])mod=n-i;
            C[i]=A[i];
        }
        if(mod==-1)return false;
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                C[n+i]=C[n+i]|(C[i+j]&B[j]);
            }
        }
        vector<char> used(mod);
        for(i=n;i<N*N;i+=mod){
            for(j=0;j<mod;j++){
                if(used[j] || !C[i+j])continue;
                for(k=1;k<=n;k++){
                    if(B[n-k])C[i+j+k]=1;
                }
                used[j]=1;
            }
            for(j=0;j<mod;j++){
                C[i+mod+j]=C[i+mod+j]|C[i+j];
            }
        }
        if(m<N*N)return C[m];
        LL pos=m-(m-i)/mod*mod;
        return C[pos];
    }

    void solve(){
        LL i,j,k;
        LL a,b,c;
        cin>>n>>m;
        vector<LL> v1,va,vb;
        for(i=0;i<n;i++){
            cin>>a;
            va.push_back(a);
            v1.push_back(a);
        }
        for(i=0;i<n;i++){
            cin>>a;
            vb.push_back(a);
            v1.push_back(a);
        }
        sort(v1.begin(),v1.end());
        LL z[3]={-1,v1.size()};
        while(z[1]-z[0]>1){
            z[2]=(z[0]+z[1])/2;
            a=v1[z[2]];
            A.reset(),B.reset();
            for(i=0;i<n;i++){
                if(va[i]>=a)A.set(i,1);
                if(vb[i]>=a)B.set(i,1);
            }
            if(check())z[0]=z[2];
            else z[1]=z[2];
        }
        cout<<v1[z[0]]<<endl;
    }
}

int main(){
    sol::solve();
}
0