結果

問題 No.1460 Max of Min
ユーザー e869120e869120
提出日時 2021-03-31 21:38:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,153 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 81,620 KB
実行使用メモリ 22,060 KB
最終ジャッジ日時 2023-08-22 00:09:47
合計ジャッジ時間 79,649 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,400 KB
testcase_01 AC 2 ms
5,728 KB
testcase_02 AC 2 ms
5,400 KB
testcase_03 AC 1,915 ms
9,576 KB
testcase_04 AC 1,913 ms
9,620 KB
testcase_05 AC 2 ms
5,520 KB
testcase_06 AC 1,914 ms
9,564 KB
testcase_07 AC 1,913 ms
9,552 KB
testcase_08 AC 26 ms
21,836 KB
testcase_09 AC 25 ms
22,060 KB
testcase_10 AC 1,913 ms
9,556 KB
testcase_11 AC 1,912 ms
9,512 KB
testcase_12 AC 1,912 ms
18,008 KB
testcase_13 AC 1,913 ms
9,504 KB
testcase_14 AC 1,912 ms
13,648 KB
testcase_15 AC 1,911 ms
19,784 KB
testcase_16 AC 1,913 ms
11,600 KB
testcase_17 AC 1,912 ms
11,596 KB
testcase_18 AC 539 ms
21,852 KB
testcase_19 AC 1,913 ms
13,648 KB
testcase_20 AC 722 ms
21,884 KB
testcase_21 AC 1,309 ms
21,832 KB
testcase_22 AC 1,912 ms
13,604 KB
testcase_23 AC 495 ms
21,920 KB
testcase_24 AC 1,912 ms
11,548 KB
testcase_25 AC 449 ms
21,920 KB
testcase_26 AC 1,912 ms
9,572 KB
testcase_27 AC 1,911 ms
19,736 KB
testcase_28 AC 1,077 ms
21,836 KB
testcase_29 AC 1,913 ms
11,884 KB
testcase_30 AC 1,912 ms
9,512 KB
testcase_31 AC 1,912 ms
13,620 KB
testcase_32 AC 22 ms
5,400 KB
testcase_33 AC 3 ms
5,412 KB
testcase_34 AC 15 ms
5,412 KB
testcase_35 AC 6 ms
5,596 KB
testcase_36 WA -
testcase_37 AC 9 ms
5,540 KB
testcase_38 AC 5 ms
5,416 KB
testcase_39 AC 15 ms
5,400 KB
testcase_40 AC 13 ms
5,476 KB
testcase_41 AC 8 ms
5,524 KB
testcase_42 AC 4 ms
5,452 KB
testcase_43 AC 520 ms
7,520 KB
testcase_44 AC 833 ms
7,452 KB
testcase_45 AC 10 ms
5,680 KB
testcase_46 AC 143 ms
5,544 KB
testcase_47 AC 151 ms
5,568 KB
testcase_48 AC 1,616 ms
9,556 KB
testcase_49 AC 834 ms
7,652 KB
testcase_50 AC 9 ms
5,516 KB
testcase_51 AC 605 ms
7,448 KB
testcase_52 AC 92 ms
5,400 KB
testcase_53 AC 7 ms
5,472 KB
testcase_54 AC 8 ms
5,464 KB
testcase_55 AC 1,414 ms
9,700 KB
testcase_56 AC 7 ms
5,536 KB
testcase_57 AC 150 ms
5,604 KB
testcase_58 AC 1,911 ms
9,632 KB
testcase_59 AC 91 ms
5,544 KB
testcase_60 AC 182 ms
5,416 KB
testcase_61 AC 9 ms
5,408 KB
testcase_62 AC 9 ms
5,528 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 AC 1,912 ms
9,524 KB
testcase_66 AC 9 ms
5,420 KB
testcase_67 AC 3 ms
5,412 KB
testcase_68 AC 243 ms
5,408 KB
testcase_69 AC 65 ms
5,412 KB
testcase_70 AC 22 ms
5,540 KB
testcase_71 AC 987 ms
7,468 KB
testcase_72 AC 8 ms
5,408 KB
testcase_73 AC 8 ms
5,480 KB
testcase_74 AC 7 ms
5,536 KB
testcase_75 AC 6 ms
5,460 KB
testcase_76 AC 6 ms
5,540 KB
testcase_77 AC 6 ms
5,400 KB
testcase_78 AC 4 ms
5,404 KB
testcase_79 AC 7 ms
5,416 KB
testcase_80 AC 6 ms
5,416 KB
testcase_81 AC 3 ms
5,476 KB
testcase_82 AC 6 ms
5,404 KB
testcase_83 AC 4 ms
5,408 KB
testcase_84 AC 1,912 ms
9,560 KB
testcase_85 AC 1,913 ms
9,500 KB
testcase_86 AC 1,912 ms
9,636 KB
testcase_87 AC 1,914 ms
9,496 KB
testcase_88 AC 1,915 ms
9,836 KB
testcase_89 AC 1,914 ms
9,512 KB
testcase_90 AC 1,911 ms
9,500 KB
testcase_91 AC 1,913 ms
9,568 KB
testcase_92 AC 1,912 ms
9,552 KB
testcase_93 AC 1,913 ms
9,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, K;
long long A[1 << 22], B[1 << 22];

int main() {
	// Step #1. 入力
	cin >> K >> N;
	for (int i = 0; i < K; i++) cin >> A[i];
	for (int i = 0; i < K; i++) cin >> B[i];

	// Step #2. 愚直解
	long long ti = clock(), rem = K - 1;
	for (long long i = K; i <= min(N, (1LL << 21)); i++) {
		A[i] = -(1LL << 60); rem = i;
		for (int j = 0; j < K; j++) {
			A[i] = max(A[i], min(B[j], A[i - K + j]));
		}
		if (i % 1000 == 0 && clock() - ti >= 19 * CLOCKS_PER_SEC / 10) {
			break;
		}
	}
	if (rem == N) {
		cout << A[N] << endl;
		return 0;
	}
	
	// Step #3. 周期を見る
	long long pr = -1;
	for (long long i = rem - 1; i >= K; i--) {
		bool flag = false;
		for (int j = 0; j < K; j++) {
			if (A[rem - K + j] != A[i - K + j]) { flag = true; break; }
		}
		if (flag == false) { pr = rem - i; break; }
	}
	
	// Step #4. 答えを出力
	long long idx = (rem - pr) + (N - rem) % pr;
	cout << A[idx] << endl;
	return 0;
}
0