結果

問題 No.1460 Max of Min
ユーザー 👑 potato167potato167
提出日時 2022-03-13 17:05:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,057 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 214,248 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2023-10-19 04:03:09
合計ジャッジ時間 15,511 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 401 ms
11,212 KB
testcase_04 AC 415 ms
11,212 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 430 ms
11,212 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 AC 448 ms
11,212 KB
testcase_12 AC 25 ms
4,852 KB
testcase_13 AC 150 ms
10,420 KB
testcase_14 AC 43 ms
5,912 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 110 ms
10,156 KB
testcase_17 AC 59 ms
7,456 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 59 ms
6,712 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 8 ms
4,348 KB
testcase_22 AC 71 ms
6,972 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 87 ms
7,984 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 150 ms
10,948 KB
testcase_27 AC 19 ms
4,580 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 74 ms
7,504 KB
testcase_30 AC 118 ms
10,420 KB
testcase_31 AC 61 ms
7,192 KB
testcase_32 AC 23 ms
9,620 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 13 ms
6,444 KB
testcase_35 AC 5 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 11 ms
7,456 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 8 ms
5,608 KB
testcase_40 AC 7 ms
4,848 KB
testcase_41 AC 6 ms
4,552 KB
testcase_42 AC 4 ms
4,348 KB
testcase_43 AC 34 ms
6,972 KB
testcase_44 AC 53 ms
9,360 KB
testcase_45 AC 3 ms
4,348 KB
testcase_46 AC 19 ms
6,176 KB
testcase_47 AC 27 ms
6,976 KB
testcase_48 AC 71 ms
9,884 KB
testcase_49 AC 35 ms
8,248 KB
testcase_50 AC 3 ms
4,348 KB
testcase_51 AC 30 ms
7,240 KB
testcase_52 AC 8 ms
4,348 KB
testcase_53 AC 9 ms
7,456 KB
testcase_54 AC 15 ms
11,152 KB
testcase_55 AC 79 ms
11,208 KB
testcase_56 AC 3 ms
4,348 KB
testcase_57 AC 49 ms
11,212 KB
testcase_58 AC 426 ms
11,208 KB
testcase_59 AC 58 ms
11,208 KB
testcase_60 AC 50 ms
11,208 KB
testcase_61 AC 15 ms
11,152 KB
testcase_62 AC 16 ms
11,152 KB
testcase_63 AC 3 ms
4,348 KB
testcase_64 AC 2 ms
4,348 KB
testcase_65 AC 88 ms
11,212 KB
testcase_66 AC 15 ms
11,152 KB
testcase_67 AC 2 ms
4,348 KB
testcase_68 AC 60 ms
11,208 KB
testcase_69 AC 43 ms
11,208 KB
testcase_70 AC 27 ms
11,212 KB
testcase_71 AC 76 ms
11,208 KB
testcase_72 AC 15 ms
11,152 KB
testcase_73 AC 15 ms
11,152 KB
testcase_74 AC 3 ms
4,348 KB
testcase_75 AC 3 ms
4,348 KB
testcase_76 AC 3 ms
4,348 KB
testcase_77 AC 3 ms
4,348 KB
testcase_78 AC 3 ms
4,348 KB
testcase_79 AC 3 ms
4,348 KB
testcase_80 AC 3 ms
4,348 KB
testcase_81 AC 3 ms
4,348 KB
testcase_82 AC 3 ms
4,348 KB
testcase_83 AC 3 ms
4,348 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます

ソースコード

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<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));
            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];
	cout<<kitamasa<ll,op1,op2,e>(B,A,N)<<"\n";
}
0