結果

問題 No.1460 Max of Min
ユーザー moririn2528_cmoririn2528_c
提出日時 2021-03-31 23:06:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,877 bytes
コンパイル時間 1,049 ms
コンパイル使用メモリ 113,660 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-09 09:58:41
合計ジャッジ時間 8,132 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
6,816 KB
testcase_01 AC 16 ms
6,940 KB
testcase_02 AC 22 ms
6,940 KB
testcase_03 AC 73 ms
6,944 KB
testcase_04 AC 73 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 27 ms
6,940 KB
testcase_09 AC 19 ms
6,940 KB
testcase_10 AC 60 ms
6,944 KB
testcase_11 AC 63 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 62 ms
6,944 KB
testcase_14 AC 53 ms
6,940 KB
testcase_15 AC 49 ms
6,940 KB
testcase_16 AC 59 ms
6,940 KB
testcase_17 AC 63 ms
6,940 KB
testcase_18 AC 39 ms
6,940 KB
testcase_19 AC 51 ms
6,944 KB
testcase_20 AC 43 ms
6,940 KB
testcase_21 AC 54 ms
6,940 KB
testcase_22 AC 53 ms
6,940 KB
testcase_23 AC 44 ms
6,944 KB
testcase_24 WA -
testcase_25 AC 43 ms
6,940 KB
testcase_26 AC 66 ms
6,944 KB
testcase_27 AC 52 ms
6,940 KB
testcase_28 WA -
testcase_29 AC 61 ms
6,944 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 61 ms
6,944 KB
testcase_33 WA -
testcase_34 AC 57 ms
6,940 KB
testcase_35 AC 51 ms
6,944 KB
testcase_36 AC 3 ms
6,940 KB
testcase_37 AC 61 ms
6,940 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 48 ms
6,944 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 41 ms
6,944 KB
testcase_46 AC 53 ms
6,944 KB
testcase_47 WA -
testcase_48 AC 60 ms
6,944 KB
testcase_49 WA -
testcase_50 AC 47 ms
6,944 KB
testcase_51 AC 55 ms
6,940 KB
testcase_52 WA -
testcase_53 AC 64 ms
6,940 KB
testcase_54 WA -
testcase_55 AC 62 ms
6,940 KB
testcase_56 AC 58 ms
6,944 KB
testcase_57 AC 72 ms
6,944 KB
testcase_58 AC 68 ms
6,940 KB
testcase_59 AC 61 ms
6,944 KB
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 3 ms
6,940 KB
testcase_64 AC 3 ms
6,944 KB
testcase_65 WA -
testcase_66 AC 60 ms
6,940 KB
testcase_67 AC 59 ms
6,940 KB
testcase_68 AC 58 ms
6,944 KB
testcase_69 AC 60 ms
6,944 KB
testcase_70 AC 65 ms
6,940 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 AC 58 ms
6,940 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 60 ms
6,940 KB
testcase_81 WA -
testcase_82 AC 60 ms
6,940 KB
testcase_83 WA -
testcase_84 AC 60 ms
6,940 KB
testcase_85 AC 59 ms
6,940 KB
testcase_86 AC 61 ms
6,944 KB
testcase_87 AC 61 ms
6,940 KB
testcase_88 AC 62 ms
6,944 KB
testcase_89 AC 61 ms
6,940 KB
testcase_90 AC 61 ms
6,940 KB
testcase_91 AC 61 ms
6,944 KB
testcase_92 AC 64 ms
6,944 KB
testcase_93 AC 62 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void sol::solve()':
main.cpp:100:29: warning: narrowing conversion of 'v1.std::vector<long long int>::size()' from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
  100 |         int 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 int 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<mod;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];
        i-=mod;
        int pos=m-(m-i)/mod*mod;
        return C[pos];
    }

    void solve(){
        int 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());
        int 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