結果
| 問題 | No.1460 Max of Min |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 22:00:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 945 bytes |
| 記録 | |
| コンパイル時間 | 1,045 ms |
| コンパイル使用メモリ | 78,948 KB |
| 実行使用メモリ | 17,948 KB |
| 最終ジャッジ日時 | 2024-12-15 18:37:05 |
| 合計ジャッジ時間 | 62,579 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 34 TLE * 19 |
コンパイルメッセージ
main.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
38 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long N;
int K;
long A[1010],B[1010];
vector<long>succ(vector<long>F)
{
long nxt=-9e18;
for(int i=0;i<K;i++)nxt=max(nxt,min(F[i],B[i]));
vector<long>ret(F.begin()+1,F.end());
ret.push_back(nxt);
return ret;
}
vector<long>dbl(vector<long>F)
{
vector<vector<long> >A(K);
for(int i=0;i<K;i++)
{
A[i]=F;
F=succ(F);
}
vector<long>ret(K,(long)-9e18);
for(int i=0;i<K;i++)for(int j=0;j<K;j++)
{
if(B[i]<=B[j])
{
ret[i]=max(ret[i],A[i][j]);
}
else
{
ret[j]=max(ret[j],A[i][j]);
}
}
return ret;
}
main()
{
cin>>K>>N;
for(int i=0;i<K;i++)cin>>A[i];
for(int i=0;i<K;i++)cin>>B[i];
if(N<K)
{
cout<<A[N]<<endl;
return 0;
}
vector<long>F(A,A+K);//K
int w=0;
while(N>=K<<w)w++;
w--;
int T=K;
while(N>=(T+1)<<w)
{
T++;
F=succ(F);
}
for(int I=w-1;I>=0;I--)
{
F=dbl(F);
if(N>>I&1)F=succ(F);
}
cout<<succ(F)[K-1]<<endl;
}