結果
| 問題 | No.1460 Max of Min |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 22:42:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 628 bytes |
| 記録 | |
| コンパイル時間 | 948 ms |
| コンパイル使用メモリ | 88,736 KB |
| 実行使用メモリ | 814,848 KB |
| 最終ジャッジ日時 | 2024-12-15 20:52:32 |
| 合計ジャッジ時間 | 29,833 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 77 MLE * 14 |
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
17 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
long N;
int K;
long A[1010],B[1010];
vector<long>succ(vector<long>F)
{
long nxt=-9e18;
for(int j=0;j<K;j++)nxt=max(nxt,min(F[j],B[j]));
F.erase(F.begin());
F.push_back(nxt);
return F;
}
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);
N-=K;
map<vector<long>,int>mp;
int now=0;
mp[F]=now;
while(N>0)
{
N--;
F=succ(F);
now++;
if(mp.find(F)!=mp.end())N%=now-mp[F];
else mp[F]=now;
}
cout<<succ(F)[K-1]<<endl;
}