結果

問題 No.1460 Max of Min
ユーザー kotatsugamekotatsugame
提出日時 2021-03-31 22:50:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 819 bytes
コンパイル時間 966 ms
コンパイル使用メモリ 88,852 KB
実行使用メモリ 391,424 KB
最終ジャッジ日時 2024-05-09 09:31:32
合計ジャッジ時間 18,106 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 24 ms
20,096 KB
testcase_07 AC 275 ms
231,168 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 6 ms
6,656 KB
testcase_13 WA -
testcase_14 AC 12 ms
11,392 KB
testcase_15 AC 5 ms
6,528 KB
testcase_16 AC 493 ms
363,520 KB
testcase_17 AC 404 ms
284,288 KB
testcase_18 AC 12 ms
8,320 KB
testcase_19 WA -
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 6 ms
6,144 KB
testcase_22 AC 35 ms
31,488 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 169 ms
115,968 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 499 ms
386,048 KB
testcase_27 AC 254 ms
159,744 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 442 ms
292,608 KB
testcase_30 AC 259 ms
195,328 KB
testcase_31 AC 16 ms
15,488 KB
testcase_32 AC 62 ms
57,216 KB
testcase_33 AC 3 ms
5,376 KB
testcase_34 AC 45 ms
38,272 KB
testcase_35 AC 13 ms
12,032 KB
testcase_36 AC 3 ms
5,376 KB
testcase_37 AC 19 ms
18,688 KB
testcase_38 AC 5 ms
5,760 KB
testcase_39 AC 46 ms
38,144 KB
testcase_40 AC 41 ms
34,560 KB
testcase_41 AC 19 ms
16,512 KB
testcase_42 AC 11 ms
10,496 KB
testcase_43 AC 255 ms
190,720 KB
testcase_44 AC 218 ms
179,072 KB
testcase_45 AC 8 ms
7,168 KB
testcase_46 AC 448 ms
237,056 KB
testcase_47 AC 133 ms
103,552 KB
testcase_48 AC 474 ms
359,040 KB
testcase_49 AC 13 ms
14,208 KB
testcase_50 AC 4 ms
5,504 KB
testcase_51 WA -
testcase_52 AC 141 ms
83,200 KB
testcase_53 AC 14 ms
13,568 KB
testcase_54 AC 12 ms
12,672 KB
testcase_55 AC 601 ms
391,296 KB
testcase_56 AC 10 ms
9,856 KB
testcase_57 WA -
testcase_58 AC 382 ms
282,496 KB
testcase_59 AC 324 ms
263,040 KB
testcase_60 AC 578 ms
391,296 KB
testcase_61 AC 19 ms
17,024 KB
testcase_62 AC 17 ms
17,024 KB
testcase_63 AC 3 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 384 ms
317,952 KB
testcase_66 AC 17 ms
16,128 KB
testcase_67 AC 4 ms
5,376 KB
testcase_68 AC 307 ms
245,504 KB
testcase_69 AC 215 ms
185,472 KB
testcase_70 AC 59 ms
55,680 KB
testcase_71 AC 505 ms
376,960 KB
testcase_72 AC 13 ms
13,184 KB
testcase_73 AC 13 ms
13,056 KB
testcase_74 AC 11 ms
11,392 KB
testcase_75 AC 8 ms
8,832 KB
testcase_76 AC 8 ms
8,704 KB
testcase_77 AC 10 ms
9,728 KB
testcase_78 AC 4 ms
5,376 KB
testcase_79 AC 11 ms
10,752 KB
testcase_80 AC 7 ms
6,784 KB
testcase_81 AC 4 ms
5,376 KB
testcase_82 AC 7 ms
7,680 KB
testcase_83 AC 5 ms
5,504 KB
testcase_84 AC 422 ms
314,112 KB
testcase_85 AC 543 ms
385,152 KB
testcase_86 AC 15 ms
14,464 KB
testcase_87 AC 234 ms
174,592 KB
testcase_88 AC 459 ms
311,168 KB
testcase_89 AC 45 ms
41,856 KB
testcase_90 AC 675 ms
386,048 KB
testcase_91 AC 498 ms
390,528 KB
testcase_92 AC 96 ms
84,736 KB
testcase_93 AC 315 ms
233,088 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
long N;
int K;
long A[1010],B[1010];
const int LIM=50000;
long T[LIM];
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];
	for(int i=0;i<K;i++)T[i]=A[i];
	if(N<K)
	{
		cout<<A[N]<<endl;
		return 0;
	}
	vector<long>F(A,A+K);
	long U=N-K;
	map<vector<long>,int>mp;
	int now=K;
	mp[F]=now;
	while(U>0&&now<LIM)
	{
		U--;
		F=succ(F);
		T[now]=F[K-1];
		now++;
		if(mp.find(F)!=mp.end())U%=now-mp[F];
		else mp[F]=now;
	}
	if(U==0)cout<<succ(F)[K-1]<<endl;
	else
	{
		if(N>=LIM)
		{
			N-=LIM;
			N%=K;
			N+=LIM-K;
		}
		cout<<T[N]<<endl;
	}
}
0