結果
| 問題 | No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩 |
| コンテスト | |
| ユーザー |
👑 Kazun
|
| 提出日時 | 2020-10-21 18:25:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,323 bytes |
| 記録 | |
| コンパイル時間 | 1,200 ms |
| コンパイル使用メモリ | 89,236 KB |
| 実行使用メモリ | 814,756 KB |
| 最終ジャッジ日時 | 2024-12-27 18:29:21 |
| 合計ジャッジ時間 | 102,612 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 TLE * 2 MLE * 49 |
ソースコード
/*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;
}
Kazun