結果
| 問題 | 
                            No.1460 Max of Min
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-03-29 14:26:31 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 136 ms / 2,000 ms | 
| コード長 | 1,197 bytes | 
| コンパイル時間 | 1,540 ms | 
| コンパイル使用メモリ | 177,964 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-30 01:50:12 | 
| 合計ジャッジ時間 | 4,582 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 91 | 
コンパイルメッセージ
main.cpp: In function 'bool check(ll)':
main.cpp:25:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   25 |         auto[c,v]=Q.top();Q.pop();
      |             ^
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,int>;
constexpr ll INF=(ll)(1e18)+1;
bool chmin(ll&a,ll b){return a>b?a=b,true:false;}
int K;
ll N,A[10005],B[10005];
bool check(ll X){
    vector<int>b;
    for(int i=K-1;i>=0;i--){
        if(B[i]>=X)b.push_back(K-i);
    }
    if(b.size()==0)return N<K && A[N]>=X;
    int M=b[0];
    vector<ll>dist(K+M,INF);
    priority_queue<P,vector<P>,greater<P>>Q;
    for(int i=0;i<K;i++){
        if(A[i]>=X){
            dist[i]=i;
            Q.push({i,i});
        }
    }
    while(!Q.empty()){
        auto[c,v]=Q.top();Q.pop();
        if(dist[v]<c)continue;
        for(int j:b){
            if(v<K){
                if(v+j>=K && chmin(dist[K+(v+j)%M],c+j))Q.push({c+j,K+(v+j)%M});
            }else{
                if(chmin(dist[K+(v-K+j)%M],c+j))Q.push({c+j,K+(v-K+j)%M});
            }
        }
    }
    if(N<K)return dist[N]<=N;
    else return dist[K+N%M]<=N;
}
int main(){
    cin>>K>>N;
    for(int i=0;i<K;i++)cin>>A[i];
    for(int i=0;i<K;i++)cin>>B[i];
    ll ok=-INF,ng=INF;
    while(ng-ok>1){
        ll mid=(ok+ng)/2;
        if(check(mid))ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
}