結果

問題 No.1460 Max of Min
ユーザー e869120e869120
提出日時 2021-03-31 21:51:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,493 bytes
コンパイル時間 873 ms
コンパイル使用メモリ 89,480 KB
実行使用メモリ 11,916 KB
最終ジャッジ日時 2023-08-22 01:12:09
合計ジャッジ時間 72,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,568 KB
testcase_01 AC 3 ms
9,508 KB
testcase_02 AC 3 ms
9,564 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 3 ms
9,552 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 3 ms
9,560 KB
testcase_09 AC 3 ms
9,504 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 237 ms
9,572 KB
testcase_13 TLE -
testcase_14 AC 454 ms
9,584 KB
testcase_15 AC 139 ms
9,508 KB
testcase_16 TLE -
testcase_17 AC 919 ms
9,848 KB
testcase_18 AC 6 ms
9,516 KB
testcase_19 AC 717 ms
9,652 KB
testcase_20 AC 9 ms
9,708 KB
testcase_21 AC 39 ms
9,568 KB
testcase_22 AC 784 ms
9,728 KB
testcase_23 AC 5 ms
9,568 KB
testcase_24 AC 1,115 ms
11,588 KB
testcase_25 AC 5 ms
9,700 KB
testcase_26 TLE -
testcase_27 AC 150 ms
9,564 KB
testcase_28 AC 24 ms
9,572 KB
testcase_29 AC 1,006 ms
11,572 KB
testcase_30 TLE -
testcase_31 AC 831 ms
9,852 KB
testcase_32 AC 22 ms
9,596 KB
testcase_33 AC 5 ms
9,664 KB
testcase_34 AC 16 ms
9,540 KB
testcase_35 AC 7 ms
9,504 KB
testcase_36 AC 3 ms
9,504 KB
testcase_37 AC 9 ms
9,664 KB
testcase_38 AC 5 ms
9,528 KB
testcase_39 AC 15 ms
9,544 KB
testcase_40 AC 13 ms
9,712 KB
testcase_41 AC 9 ms
9,632 KB
testcase_42 AC 5 ms
9,516 KB
testcase_43 AC 498 ms
9,536 KB
testcase_44 AC 803 ms
9,544 KB
testcase_45 AC 11 ms
9,560 KB
testcase_46 AC 140 ms
9,856 KB
testcase_47 AC 146 ms
9,544 KB
testcase_48 AC 1,590 ms
11,656 KB
testcase_49 AC 810 ms
9,664 KB
testcase_50 AC 10 ms
9,504 KB
testcase_51 AC 594 ms
9,648 KB
testcase_52 AC 88 ms
9,640 KB
testcase_53 AC 8 ms
9,584 KB
testcase_54 AC 9 ms
9,540 KB
testcase_55 AC 1,363 ms
11,632 KB
testcase_56 AC 8 ms
9,548 KB
testcase_57 AC 147 ms
9,656 KB
testcase_58 TLE -
testcase_59 AC 86 ms
9,552 KB
testcase_60 AC 176 ms
9,736 KB
testcase_61 AC 11 ms
9,540 KB
testcase_62 AC 11 ms
9,532 KB
testcase_63 AC 5 ms
9,540 KB
testcase_64 AC 4 ms
9,536 KB
testcase_65 TLE -
testcase_66 AC 11 ms
9,600 KB
testcase_67 AC 5 ms
9,668 KB
testcase_68 AC 234 ms
9,540 KB
testcase_69 AC 64 ms
9,736 KB
testcase_70 AC 23 ms
9,548 KB
testcase_71 AC 960 ms
9,592 KB
testcase_72 AC 9 ms
9,812 KB
testcase_73 AC 9 ms
9,592 KB
testcase_74 AC 8 ms
9,600 KB
testcase_75 AC 7 ms
9,536 KB
testcase_76 AC 7 ms
9,732 KB
testcase_77 AC 8 ms
9,544 KB
testcase_78 AC 5 ms
9,584 KB
testcase_79 AC 8 ms
9,548 KB
testcase_80 AC 7 ms
9,536 KB
testcase_81 AC 5 ms
9,604 KB
testcase_82 AC 7 ms
9,548 KB
testcase_83 AC 6 ms
9,544 KB
testcase_84 TLE -
testcase_85 TLE -
testcase_86 TLE -
testcase_87 TLE -
testcase_88 TLE -
testcase_89 TLE -
testcase_90 TLE -
testcase_91 TLE -
testcase_92 TLE -
testcase_93 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:37:24: 警告: overflow in conversion from ‘long long int’ to ‘int’ changes value from ‘-1152921504606846976’ to ‘0’ [-Woverflow]
   37 |                 A[i] = -(1LL << 60);
      |                        ^~~~~~~~~~~~

ソースコード

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)

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

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

	// Step #2. 座標圧縮
	vector<long long> X;
	for (int i = 0; i < K; i++) X.push_back(QA[i]);
	for (int i = 0; i < K; i++) X.push_back(QB[i]);
	sort(X.begin(), X.end());
	X.erase(unique(X.begin(), X.end()), X.end());
	for (int i = 0; i < K; i++) A[i] = lower_bound(X.begin(), X.end(), QA[i]) - X.begin();
	for (int i = 0; i < K; i++) B[i] = lower_bound(X.begin(), X.end(), QB[i]) - X.begin();

	// Step #3. 愚直解
	int rem = min(N, 1LL * K * K);
	for (int i = K; i <= rem; i++) {
		A[i] = -(1LL << 60);
		for (int j = 0; j < K; j++) {
			A[i] = max(A[i], min(B[j], A[i - K + j]));
		}
	}
	if (rem == N) {
		cout << X[A[N]] << endl;
		return 0;
	}
	
	// Step #4. 周期を見る
	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 #5. 答えを出力
	long long idx = (rem - pr) + (N - rem) % pr;
	cout << X[A[idx]] << endl;
	return 0;
}
0