結果

問題 No.1460 Max of Min
ユーザー butsurizukibutsurizuki
提出日時 2021-03-30 05:38:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,610 bytes
コンパイル時間 9,856 ms
コンパイル使用メモリ 350,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 10:14:13
合計ジャッジ時間 17,134 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 154 ms
5,376 KB
testcase_04 AC 151 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 155 ms
5,376 KB
testcase_07 AC 150 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 139 ms
5,376 KB
testcase_11 AC 152 ms
5,376 KB
testcase_12 AC 32 ms
5,376 KB
testcase_13 AC 125 ms
5,376 KB
testcase_14 AC 46 ms
5,376 KB
testcase_15 AC 20 ms
5,376 KB
testcase_16 AC 133 ms
5,376 KB
testcase_17 AC 82 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 56 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 10 ms
5,376 KB
testcase_22 AC 65 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 88 ms
5,376 KB
testcase_25 AC 3 ms
5,376 KB
testcase_26 AC 146 ms
5,376 KB
testcase_27 AC 23 ms
5,376 KB
testcase_28 AC 7 ms
5,376 KB
testcase_29 AC 84 ms
5,376 KB
testcase_30 AC 155 ms
5,376 KB
testcase_31 AC 77 ms
5,376 KB
testcase_32 AC 4 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 3 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 3 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 3 ms
5,376 KB
testcase_41 AC 3 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 46 ms
5,376 KB
testcase_44 AC 51 ms
5,376 KB
testcase_45 AC 4 ms
5,376 KB
testcase_46 AC 15 ms
5,376 KB
testcase_47 AC 15 ms
5,376 KB
testcase_48 AC 106 ms
5,376 KB
testcase_49 AC 66 ms
5,376 KB
testcase_50 AC 4 ms
5,376 KB
testcase_51 AC 48 ms
5,376 KB
testcase_52 AC 16 ms
5,376 KB
testcase_53 AC 3 ms
5,376 KB
testcase_54 AC 4 ms
5,376 KB
testcase_55 AC 84 ms
5,376 KB
testcase_56 AC 3 ms
5,376 KB
testcase_57 AC 12 ms
5,376 KB
testcase_58 AC 152 ms
5,376 KB
testcase_59 AC 8 ms
5,376 KB
testcase_60 AC 13 ms
5,376 KB
testcase_61 AC 3 ms
5,376 KB
testcase_62 AC 3 ms
5,376 KB
testcase_63 AC 3 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 142 ms
5,376 KB
testcase_66 AC 3 ms
5,376 KB
testcase_67 AC 3 ms
5,376 KB
testcase_68 AC 16 ms
5,376 KB
testcase_69 AC 6 ms
5,376 KB
testcase_70 AC 4 ms
5,376 KB
testcase_71 AC 57 ms
5,376 KB
testcase_72 AC 3 ms
5,376 KB
testcase_73 AC 3 ms
5,376 KB
testcase_74 AC 3 ms
5,376 KB
testcase_75 AC 3 ms
5,376 KB
testcase_76 AC 3 ms
5,376 KB
testcase_77 AC 2 ms
5,376 KB
testcase_78 AC 3 ms
5,376 KB
testcase_79 AC 3 ms
5,376 KB
testcase_80 AC 3 ms
5,376 KB
testcase_81 AC 3 ms
5,376 KB
testcase_82 AC 3 ms
5,376 KB
testcase_83 AC 3 ms
5,376 KB
testcase_84 AC 135 ms
5,376 KB
testcase_85 AC 137 ms
5,376 KB
testcase_86 AC 134 ms
5,376 KB
testcase_87 AC 137 ms
5,376 KB
testcase_88 AC 137 ms
5,376 KB
testcase_89 AC 155 ms
5,376 KB
testcase_90 AC 152 ms
5,376 KB
testcase_91 AC 156 ms
5,376 KB
testcase_92 AC 156 ms
5,376 KB
testcase_93 AC 152 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include "testlib.h"

using namespace std;

long long k,n,cyc;
bool jud(bitset<1024> a,bitset<1024> b){
  if(cyc==1000000007){return false;}
  for(long long i=k;i<=(10+k)*k;i++){
    if((a&b).any()){
      a<<=1;
      a.set(0);
    }
    else{a<<=1;}
    a.reset(k);
    if(i==n){
      if(a[0]){return true;}
      return false;
    }
  }
  long long cid=((10+k)*k);
  for(long long i=0;;i++){
    if(cid%cyc==n%cyc){
      if(a[i]){return true;}
      return false;
    }
    cid--;
  }
}

int main(int argc, char* argv[]){
  registerValidation(argc, argv);
  k=inf.readLong(1ll,1000ll);inf.readSpace();
  n=inf.readLong(0ll,1000000000000000000ll);inf.readEoln();
  vector<long long> a=inf.readLongs(k,-1000000000000000000ll,1000000000000000000ll);inf.readEoln();
  vector<long long> b=inf.readLongs(k,-1000000000000000000ll,1000000000000000000ll);inf.readEoln();
  inf.readEof();
  if(n<k){cout << a[n] << '\n';return 0;}
  vector<long long> ser;
  for(auto &nx : a){ser.push_back(nx);}
  for(auto &nx : b){ser.push_back(nx);}
  sort(ser.begin(),ser.end());
  int st=0,fi=ser.size()-1,te;
  while(st<=fi){
    te=(st+fi)/2;
    bitset<1024> ba,bb;
    for(int i=0;i<k;i++){
      if(a[k-1-i]>=ser[te]){ba.set(i);}
    }
    cyc=1000000007;
    for(int i=0;i<k;i++){
      if(b[k-1-i]>=ser[te]){
        bb.set(i);
        cyc=min(i+1ll,cyc);
      }
    }
    //cout << ser[te] << ' ' << cyc << '\n';
    if(jud(ba,bb)){st=te+1;}else{fi=te-1;}
  }
  cout << ser[fi] << '\n';
  return 0;
}
0