結果
| 問題 |
No.1460 Max of Min
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-03-31 21:54:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 988 bytes |
| コンパイル時間 | 4,068 ms |
| コンパイル使用メモリ | 255,424 KB |
| 最終ジャッジ日時 | 2025-01-20 03:23:40 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 TLE * 35 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000001
vector<long long> get(vector<long long> a,vector<long long> b){
long long m = -Inf;
rep(i,a.size()){
m = max(m,min(a[i],b[i]));
}
a.push_back(m);
a.erase(a.begin());
return a;
}
int main(){
long long K,N;
cin>>K>>N;
vector<long long> A(K),B(K);
rep(i,K)cin>>A[i];
rep(i,K)cin>>B[i];
if(N<K){
cout<<A[N]<<endl;
return 0;
}
N -= K-1;
long long n = N;
vector<vector<long long>> temp(1,A);
bool f = false;
while(true){
if(n==0){
f=true;
cout<<temp.back().back()<<endl;
return 0;
}
n--;
auto t = get(temp.back(),B);
rep(i,temp.size()){
if(temp[i]==t){
temp.erase(temp.begin(),temp.begin()+i);
goto L;
}
}
temp.push_back(t);
}
L:;
cout<<temp[n%temp.size()].back()<<endl;
return 0;
}
沙耶花