結果

問題 No.1460 Max of Min
ユーザー suzuken_wsuzuken_w
提出日時 2021-04-02 00:16:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 1,762 bytes
コンパイル時間 4,178 ms
コンパイル使用メモリ 215,936 KB
実行使用メモリ 11,248 KB
最終ジャッジ日時 2023-08-23 07:09:21
合計ジャッジ時間 22,513 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 317 ms
11,080 KB
testcase_04 AC 292 ms
11,056 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 286 ms
10,908 KB
testcase_07 AC 280 ms
10,988 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 350 ms
10,960 KB
testcase_11 AC 290 ms
11,132 KB
testcase_12 AC 45 ms
4,552 KB
testcase_13 AC 224 ms
10,144 KB
testcase_14 AC 69 ms
5,604 KB
testcase_15 AC 31 ms
4,408 KB
testcase_16 AC 207 ms
10,020 KB
testcase_17 AC 118 ms
7,020 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 100 ms
6,688 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 14 ms
4,376 KB
testcase_22 AC 101 ms
6,844 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 133 ms
7,712 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 228 ms
10,896 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 10 ms
4,376 KB
testcase_29 AC 120 ms
7,356 KB
testcase_30 AC 210 ms
10,124 KB
testcase_31 AC 109 ms
6,892 KB
testcase_32 AC 155 ms
9,476 KB
testcase_33 AC 51 ms
5,236 KB
testcase_34 AC 80 ms
6,300 KB
testcase_35 AC 28 ms
4,376 KB
testcase_36 AC 11 ms
4,380 KB
testcase_37 AC 101 ms
7,364 KB
testcase_38 AC 163 ms
9,800 KB
testcase_39 AC 57 ms
5,340 KB
testcase_40 AC 40 ms
4,632 KB
testcase_41 AC 29 ms
4,380 KB
testcase_42 AC 18 ms
4,380 KB
testcase_43 AC 94 ms
6,828 KB
testcase_44 AC 166 ms
9,208 KB
testcase_45 AC 6 ms
4,380 KB
testcase_46 AC 71 ms
6,000 KB
testcase_47 AC 97 ms
6,660 KB
testcase_48 AC 190 ms
9,604 KB
testcase_49 AC 125 ms
7,724 KB
testcase_50 AC 8 ms
4,380 KB
testcase_51 AC 99 ms
7,224 KB
testcase_52 AC 23 ms
4,376 KB
testcase_53 AC 103 ms
7,356 KB
testcase_54 AC 210 ms
11,120 KB
testcase_55 AC 214 ms
11,116 KB
testcase_56 AC 210 ms
10,988 KB
testcase_57 AC 213 ms
10,920 KB
testcase_58 AC 306 ms
11,120 KB
testcase_59 AC 219 ms
10,924 KB
testcase_60 AC 198 ms
10,956 KB
testcase_61 AC 199 ms
10,916 KB
testcase_62 AC 203 ms
11,168 KB
testcase_63 AC 189 ms
10,928 KB
testcase_64 AC 208 ms
11,136 KB
testcase_65 AC 234 ms
11,192 KB
testcase_66 AC 208 ms
11,248 KB
testcase_67 AC 197 ms
10,924 KB
testcase_68 AC 215 ms
10,992 KB
testcase_69 AC 223 ms
10,980 KB
testcase_70 AC 230 ms
11,164 KB
testcase_71 AC 219 ms
11,064 KB
testcase_72 AC 195 ms
11,064 KB
testcase_73 AC 196 ms
10,932 KB
testcase_74 AC 206 ms
11,012 KB
testcase_75 AC 206 ms
10,924 KB
testcase_76 AC 193 ms
10,636 KB
testcase_77 AC 201 ms
10,944 KB
testcase_78 AC 196 ms
10,960 KB
testcase_79 AC 222 ms
10,664 KB
testcase_80 AC 207 ms
10,668 KB
testcase_81 AC 200 ms
11,016 KB
testcase_82 AC 196 ms
10,804 KB
testcase_83 AC 197 ms
11,044 KB
testcase_84 AC 296 ms
10,692 KB
testcase_85 AC 290 ms
10,800 KB
testcase_86 AC 290 ms
10,792 KB
testcase_87 AC 279 ms
10,892 KB
testcase_88 AC 298 ms
11,028 KB
testcase_89 AC 298 ms
11,024 KB
testcase_90 AC 277 ms
10,856 KB
testcase_91 AC 277 ms
11,056 KB
testcase_92 AC 323 ms
10,936 KB
testcase_93 AC 288 ms
10,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}
V<ll> add(V<ll> &x,V<ll> &d){
    int k=d.size();
    V<ll> ans(k);
    ans[0]=min(d[0],x[k-1]);
    for(int i=1;i<k;i++){
         ans[i]=max(x[i-1],min(d[i],x[k-1]));
    }
    return ans;
}
V<ll> mul(V<ll> &x,V<ll> &d){
    int k=d.size();
    V<V<ll>> nxt(k);
    nxt[0]=x;
    for(int i=1;i<k;i++){
       nxt[i]=add(nxt[i-1],d);
    }
    V<ll> ans(k,-2*inf);
    for(int i=0;i<k;i++){
       for(int j=0;j<k;j++){
            chmax(ans[j],min(nxt[i][j],x[i]));
       }
    }
    return ans;
}
int main(){
  ll k,n;
  cin>>k>>n;
  V<ll> a(k),b(k);
  for(int i=0;i<k;i++)cin>>a[i];
  for(int i=0;i<k;i++)cin>>b[i];
  V<ll> c(k,-2*inf);
  c[0]=2*inf;
  for(int i=60;i>=0;i--){
        c=mul(c,b);
        if(n&(1ll<<i)){
            c=add(c,b);
        }
  }
  ll ans=-2*inf;
  for(int i=0;i<k;i++){
       chmax(ans,min(a[i],c[i]));
  }
  cout<<ans<<"\n";
}
0