結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー 👑 KazunKazun
提出日時 2020-10-21 18:25:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,323 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 88,364 KB
実行使用メモリ 814,372 KB
最終ジャッジ日時 2023-08-27 16:11:37
合計ジャッジ時間 6,020 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 98 ms
20,168 KB
testcase_09 AC 21 ms
5,272 KB
testcase_10 AC 153 ms
20,684 KB
testcase_11 AC 67 ms
11,860 KB
testcase_12 AC 49 ms
11,704 KB
testcase_13 AC 70 ms
11,812 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 363 ms
37,128 KB
testcase_16 AC 115 ms
20,624 KB
testcase_17 AC 109 ms
20,508 KB
testcase_18 MLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*Greedy解法*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;
using ll = long long;

void input(vector<ll>& X) {
	for (int i = 0; i < X.size(); i++) {
		cin >> X.at(i);
	}
}

pair<ll, ll> h(ll x, vector<ll> G, vector<ll> H) {
	if (x == 0) {
		if (find(G.begin(), G.end(), 0) != G.end()) {
			return make_pair(0, H[0]);
		}
		else {
			return make_pair(G[0], 0);
		}
	}

	set<ll> F(H.begin(), H.end());
	for (auto g : G) {
		if (g == 0) continue;

		if (x % g == 0 && F.count(x / g)) {
			return make_pair(g, x / g);
		}
	}
	return make_pair(-1, -1);
}


int main() {
	ll K, L, M, N, S, T;
	cin >> K >> L >> M >> N >> S;

	vector<ll> A(K), B(L), C(M), D(N);
	vector<ll> U(0), V(0), E(0);

	input(A); input(B); input(C); input(D);
	for (auto a : A) {
		for (auto b : B) {
			U.push_back(a * b);
		}
	}

	for (auto c : C) {
		for (auto d : D) {
			V.push_back(c * d);
		}
	}

	for (auto u : U) {
		for (auto v : V) {
			E.push_back(u * v);
		}
	}

	sort(E.begin(), E.end());
	T = E[S - 1];

	ll alpha, beta, a, b, c, d;
	pair<ll, ll> P;

	P = h(T, U, V);
	alpha = P.first; beta = P.second;

	P = h(alpha, A, B);
	a = P.first; b = P.second;

	P = h(beta, C, D);
	c = P.first; d = P.second;

	cout << T << endl;
	cout << a << " " << b << " " << c << " " << d << endl;
	return 0;
}
0