結果

問題 No.1460 Max of Min
ユーザー kotatsugamekotatsugame
提出日時 2021-03-31 22:03:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 79,668 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-09 07:54:29
合計ジャッジ時間 9,875 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 290 ms
11,136 KB
testcase_04 AC 281 ms
11,136 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 336 ms
11,136 KB
testcase_07 AC 327 ms
11,264 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 295 ms
11,136 KB
testcase_12 AC 28 ms
6,944 KB
testcase_13 WA -
testcase_14 AC 44 ms
6,940 KB
testcase_15 AC 21 ms
6,940 KB
testcase_16 AC 108 ms
9,984 KB
testcase_17 WA -
testcase_18 AC 3 ms
6,944 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 9 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 3 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 96 ms
10,368 KB
testcase_31 AC 59 ms
7,040 KB
testcase_32 WA -
testcase_33 AC 2 ms
6,940 KB
testcase_34 WA -
testcase_35 AC 6 ms
6,940 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 10 ms
7,296 KB
testcase_38 AC 3 ms
6,944 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 5 ms
6,944 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 3 ms
6,944 KB
testcase_46 WA -
testcase_47 AC 26 ms
6,940 KB
testcase_48 WA -
testcase_49 AC 35 ms
8,064 KB
testcase_50 AC 3 ms
6,944 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 8 ms
7,424 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 4 ms
6,940 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 3 ms
6,944 KB
testcase_64 AC 3 ms
6,944 KB
testcase_65 AC 71 ms
11,136 KB
testcase_66 WA -
testcase_67 AC 3 ms
6,940 KB
testcase_68 AC 53 ms
11,264 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 AC 12 ms
11,136 KB
testcase_73 WA -
testcase_74 AC 4 ms
6,940 KB
testcase_75 AC 4 ms
6,940 KB
testcase_76 AC 4 ms
6,944 KB
testcase_77 AC 4 ms
6,944 KB
testcase_78 AC 3 ms
6,944 KB
testcase_79 AC 4 ms
6,940 KB
testcase_80 AC 3 ms
6,940 KB
testcase_81 AC 3 ms
6,940 KB
testcase_82 AC 4 ms
6,940 KB
testcase_83 AC 4 ms
6,944 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 WA -
testcase_87 WA -
testcase_88 WA -
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main()
      | ^~~~

ソースコード

diff #

#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]);
		}
		if(B[i]>=B[j])
		{
			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;
	long T=K;
	while(N>=T<<w)w++;
	w--;
	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;
}
0