結果

問題 No.1460 Max of Min
ユーザー QCFiumQCFium
提出日時 2021-03-31 22:29:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,211 bytes
コンパイル時間 2,502 ms
コンパイル使用メモリ 176,184 KB
実行使用メモリ 9,552 KB
最終ジャッジ日時 2023-08-22 02:55:31
合計ジャッジ時間 10,767 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 9 ms
4,380 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 WA -
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 66 ms
5,116 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 8 ms
4,380 KB
testcase_36 WA -
testcase_37 AC 22 ms
4,460 KB
testcase_38 WA -
testcase_39 AC 9 ms
4,380 KB
testcase_40 AC 12 ms
4,380 KB
testcase_41 AC 8 ms
4,376 KB
testcase_42 AC 8 ms
4,380 KB
testcase_43 AC 13 ms
4,412 KB
testcase_44 AC 23 ms
5,052 KB
testcase_45 WA -
testcase_46 AC 10 ms
4,376 KB
testcase_47 AC 12 ms
4,388 KB
testcase_48 AC 23 ms
5,092 KB
testcase_49 WA -
testcase_50 AC 3 ms
4,380 KB
testcase_51 AC 13 ms
4,496 KB
testcase_52 AC 5 ms
4,376 KB
testcase_53 WA -
testcase_54 AC 251 ms
5,548 KB
testcase_55 AC 70 ms
5,424 KB
testcase_56 WA -
testcase_57 AC 26 ms
5,488 KB
testcase_58 AC 3 ms
4,380 KB
testcase_59 AC 43 ms
5,456 KB
testcase_60 AC 70 ms
5,440 KB
testcase_61 AC 217 ms
5,640 KB
testcase_62 AC 79 ms
5,452 KB
testcase_63 TLE -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}


int gcd(int a, int b) {
	while (a && b) {
		if (a > b) a %= b;
		else b %= a;
	}
	return a + b;
}

int main() {
	int k = ri();
	int64_t n;
	std::cin >> n;
	std::vector<int64_t> a(k + k);
	for (auto &i : a) std::cin >> i;
	std::reverse(a.begin() + k, a.end());
	
	int index[k + k];
	std::iota(index, index + k + k, 0);
	std::sort(index, index + k + k, [&] (int i, int j) { return a[i] > a[j]; });
	
	std::set<int> start;
	std::set<int> move;
	for (auto i : index) {
		if (i < k) start.insert(i);
		else move.insert(i - k);
		
		if (!move.size()) continue;
		
		int g = 0;
		for (auto j : move) g = gcd(g, j + 1);
		
		// std::cerr << "added " << i << std::endl;
		bool ok = false;
		if (n > 2 * k * k) {
			for (auto i : start) if ((n - i) % g == 0) ok = true;
		} else {
			bool dp[2 * k * k + 1];
			memset(dp, 0, sizeof(dp));
			for (auto i : start) dp[i] = true;
			for (int i = 0; i < 2 * k * k; i++) {
				if (!dp[i]) continue;
				for (auto j : move) if (i + j + 1 <= 2* k * k) dp[i + j + 1] = true;
			}
			if (dp[n]) ok = true;
		}
		if (ok) {
			printf("%" PRId64 "\n", a[i]);
			return 0;
		}
	}
	assert(0);
	
	return 0;
}
0