結果

問題 No.1460 Max of Min
ユーザー 👑 kmjpkmjp
提出日時 2021-04-02 01:29:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,783 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 208,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 08:24:42
合計ジャッジ時間 8,672 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 3 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 4 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 170 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 7 ms
4,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 5 ms
4,376 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 4 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 7 ms
4,376 KB
testcase_38 AC 5 ms
4,376 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 WA -
testcase_42 AC 3 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 5 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 11 ms
4,376 KB
testcase_49 AC 10 ms
4,380 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 3 ms
4,380 KB
testcase_53 WA -
testcase_54 AC 6 ms
4,380 KB
testcase_55 AC 10 ms
4,380 KB
testcase_56 AC 12 ms
4,376 KB
testcase_57 AC 5 ms
4,376 KB
testcase_58 AC 8 ms
4,376 KB
testcase_59 WA -
testcase_60 AC 7 ms
4,380 KB
testcase_61 AC 12 ms
4,380 KB
testcase_62 AC 16 ms
4,376 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 6 ms
4,376 KB
testcase_66 AC 6 ms
4,380 KB
testcase_67 AC 4 ms
4,380 KB
testcase_68 AC 5 ms
4,376 KB
testcase_69 AC 6 ms
4,376 KB
testcase_70 AC 8 ms
4,376 KB
testcase_71 WA -
testcase_72 AC 6 ms
4,380 KB
testcase_73 WA -
testcase_74 AC 6 ms
4,380 KB
testcase_75 AC 8 ms
4,380 KB
testcase_76 AC 11 ms
4,380 KB
testcase_77 AC 12 ms
4,380 KB
testcase_78 AC 6 ms
4,376 KB
testcase_79 WA -
testcase_80 AC 10 ms
4,380 KB
testcase_81 AC 4 ms
4,376 KB
testcase_82 AC 6 ms
4,380 KB
testcase_83 AC 11 ms
4,376 KB
testcase_84 AC 294 ms
4,380 KB
testcase_85 AC 209 ms
4,376 KB
testcase_86 AC 340 ms
4,380 KB
testcase_87 AC 336 ms
4,376 KB
testcase_88 AC 264 ms
4,380 KB
testcase_89 AC 243 ms
4,376 KB
testcase_90 AC 193 ms
4,380 KB
testcase_91 AC 314 ms
4,376 KB
testcase_92 AC 329 ms
4,376 KB
testcase_93 AC 188 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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;}
//-------------------------------------------------------

int K;
ll N;
ll A[1010],B[1010];
ll X[1010],Y[1010];
ll dp[1010];

ll ok(ll v) {
	int i;
	
	if(N<K) return A[N]>=v;
	vector<int> cand;
	FOR(i,K) if(B[K-1-i]>=v) cand.push_back(i+1);
	if(cand.empty()) return 0;
	int T=cand.back();
	cand.pop_back();
	
	priority_queue<pair<ll,ll>> Q;
	FOR(i,T) {
		ll x=K-1-i;
		if(A[x]>=v) {
			dp[x%T]=x;
			Q.push({-x,x});
		}
		else {
			dp[x%T]=1LL<<60;
		}
	}
	
	while(Q.size()) {
		ll cur=-Q.top().first;
		int tar=Q.top().second;
		Q.pop();
		if(dp[tar]!=cur) continue;
		if(cur>N) return 0;
		if(N%T==tar) return 1;
		FORR(c,cand) {
			if(cur+c>=K&&dp[(cur+c)%T]>cur+c) {
				dp[(cur+c)%T]=cur+c;
				Q.push({-(cur+c),(cur+c)%T});
			}
		}
		if(cur<K) {
			while(cur<K) cur+=T;
			dp[tar]=cur;
			Q.push({-dp[tar],tar});
		}
	}
	return 0;
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>N;
	FOR(i,K) cin>>A[i];
	FOR(i,K) cin>>B[i];
	
	ll ret=-1LL<<60;
	for(i=60;i>=0;i--) if(ok(ret+(1LL<<i))) ret+=1LL<<i;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0