結果

問題 No.1460 Max of Min
ユーザー 👑 potato167potato167
提出日時 2022-03-13 17:35:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 3,120 bytes
コンパイル時間 2,427 ms
コンパイル使用メモリ 214,436 KB
実行使用メモリ 11,260 KB
最終ジャッジ日時 2023-10-19 04:33:37
合計ジャッジ時間 14,298 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 411 ms
11,208 KB
testcase_04 AC 396 ms
11,208 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 422 ms
11,208 KB
testcase_07 AC 421 ms
11,208 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 492 ms
11,208 KB
testcase_11 AC 436 ms
11,208 KB
testcase_12 AC 25 ms
4,848 KB
testcase_13 AC 148 ms
10,416 KB
testcase_14 AC 42 ms
5,908 KB
testcase_15 AC 18 ms
4,348 KB
testcase_16 AC 108 ms
10,152 KB
testcase_17 AC 57 ms
7,452 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 57 ms
6,708 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 8 ms
4,348 KB
testcase_22 AC 67 ms
6,968 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 83 ms
7,980 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 146 ms
10,944 KB
testcase_27 AC 18 ms
4,576 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 70 ms
7,500 KB
testcase_30 AC 119 ms
10,416 KB
testcase_31 AC 59 ms
7,188 KB
testcase_32 AC 22 ms
9,616 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 13 ms
6,440 KB
testcase_35 AC 5 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 11 ms
7,452 KB
testcase_38 AC 3 ms
4,348 KB
testcase_39 AC 8 ms
5,604 KB
testcase_40 AC 8 ms
4,844 KB
testcase_41 AC 5 ms
4,548 KB
testcase_42 AC 4 ms
4,348 KB
testcase_43 AC 29 ms
6,968 KB
testcase_44 AC 50 ms
9,356 KB
testcase_45 AC 2 ms
4,348 KB
testcase_46 AC 17 ms
6,172 KB
testcase_47 AC 27 ms
6,972 KB
testcase_48 AC 73 ms
9,880 KB
testcase_49 AC 35 ms
8,244 KB
testcase_50 AC 3 ms
4,348 KB
testcase_51 AC 27 ms
7,236 KB
testcase_52 AC 7 ms
4,348 KB
testcase_53 AC 8 ms
7,452 KB
testcase_54 AC 14 ms
11,148 KB
testcase_55 AC 78 ms
11,204 KB
testcase_56 AC 4 ms
4,348 KB
testcase_57 AC 50 ms
11,208 KB
testcase_58 AC 439 ms
11,204 KB
testcase_59 AC 59 ms
11,204 KB
testcase_60 AC 52 ms
11,204 KB
testcase_61 AC 14 ms
11,148 KB
testcase_62 AC 15 ms
11,148 KB
testcase_63 AC 2 ms
4,348 KB
testcase_64 AC 3 ms
4,348 KB
testcase_65 AC 88 ms
11,208 KB
testcase_66 AC 15 ms
11,148 KB
testcase_67 AC 2 ms
4,348 KB
testcase_68 AC 62 ms
11,204 KB
testcase_69 AC 46 ms
11,204 KB
testcase_70 AC 27 ms
11,208 KB
testcase_71 AC 81 ms
11,204 KB
testcase_72 AC 15 ms
11,148 KB
testcase_73 AC 14 ms
11,148 KB
testcase_74 AC 4 ms
4,348 KB
testcase_75 AC 4 ms
4,348 KB
testcase_76 AC 3 ms
4,348 KB
testcase_77 AC 3 ms
4,348 KB
testcase_78 AC 2 ms
4,348 KB
testcase_79 AC 4 ms
4,348 KB
testcase_80 AC 4 ms
4,348 KB
testcase_81 AC 3 ms
4,348 KB
testcase_82 AC 3 ms
4,348 KB
testcase_83 AC 2 ms
4,348 KB
testcase_84 AC 393 ms
10,940 KB
testcase_85 AC 495 ms
10,944 KB
testcase_86 AC 491 ms
10,940 KB
testcase_87 AC 415 ms
11,148 KB
testcase_88 AC 388 ms
11,148 KB
testcase_89 AC 401 ms
11,148 KB
testcase_90 AC 358 ms
10,944 KB
testcase_91 AC 430 ms
11,260 KB
testcase_92 AC 460 ms
11,208 KB
testcase_93 AC 483 ms
10,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=1167167167167167167;
const int INF=2100000000;
const ll mod=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}
//a_n=c_0*a_0+c_1*a_1+...c_(n-1)*a_(n-1)
//a_ind?
//O(n^2 * log(k))
//ex.
//ll ans=kitama<ll,op1,op2>(p,q,K);
template<class T,T(*op1)(T,T),T(*op2)(T,T),T(*e)()>
T kitamasa(std::vector<T> c,std::vector<T> a,long long ind){
    int n=a.size();
    if(ind<n) return a[ind];
    std::vector<int> q;
    std::vector<T> x=c;
    while(ind!=n){
        if(ind%2||ind<=n*2+2) q.push_back(1),ind--;
        else q.push_back(0),ind/=2;
    }
    std::reverse(q.begin(),q.end());
    for(int que=0;que<(int)q.size();que++){
        //cout<<que<<" "<<q[que]<<endl;
        if(q[que]){
            auto new_x=x;
            for(int j=0;j<n;j++){
                if(j!=0) new_x[j]=op1(x[j-1],op2(x[n-1],c[j]));
                else new_x[j]=op2(x[n-1],c[j]);
            }
            std::swap(new_x,x);
        }else{
            std::vector<std::vector<T>> new_x(n+1,std::vector<T>(n,e()));
            new_x[0]=x;
            for(int k=0;k<n-1;k++){
                for(int j=0;j<n;j++){
                    if(j!=0) new_x[k+1][j]=op1(new_x[k][j-1],op2(new_x[k][n-1],c[j]));
                    else new_x[k+1][j]=op2(new_x[k][n-1],c[j]);
                }
            }
            for(int i=0;i<n;i++) for(int j=0;j<n;j++){
                new_x[n][i]=op1(new_x[n][i],op2(new_x[0][j],new_x[j][i]));
            }
            std::swap(x,new_x[n]);
        }
    }
    T ans=e();
    for(int i=0;i<n;i++){
        ans=op1(ans,op2(x[i],a[i]));
        //cout<<x[i]<<endl;
    }
    return ans;
}

using kita_F=long long;
long long kita_mod=1e9+7;
kita_F op1(kita_F x,kita_F y){
    return max(x,y);
}
kita_F op2(kita_F x,kita_F y){
    return min(x,y);
}
kita_F e(){
    return -ILL;
}

void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	//cin>>t;
	rep(i,t) solve();
}

void solve(){
	ll K,N;
	cin>>K>>N;
	vector<ll> A(K),B(K);
	rep(i,K) cin>>A[i];
	rep(i,K) cin>>B[i];
	if(K==1){
		cout<<min(A[0],B[0])<<"\n";
		return;
	}
	cout<<kitamasa<ll,op1,op2,e>(B,A,N)<<"\n";
}
0