結果
問題 |
No.2495 Three Sets
|
ユーザー |
|
提出日時 | 2023-10-07 12:02:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,369 ms / 3,000 ms |
コード長 | 1,540 bytes |
コンパイル時間 | 3,705 ms |
コンパイル使用メモリ | 256,048 KB |
最終ジャッジ日時 | 2025-02-17 06:06:18 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; struct Fast { Fast() { std::cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(10); } } fast; #define rep(i, a, b) for (int(i) = (a); (i) < (int)(b); (i)++) #define all(a) (a).begin(), (a).end() using ll = long long; const ll INF = 1e18; int main() { int na, nb, nc; cin >> na >> nb >> nc; auto read = [](const int n) { vector<ll> ret(n); rep(i, 0, n) cin >> ret[i]; sort(all(ret)); reverse(all(ret)); ret.insert(ret.begin(), 0); rep(i, 0, n) ret[i + 1] += ret[i]; return ret; }; auto a = read(na); auto b = read(nb); auto c = read(nc); auto h = [a, b, c](const int u, const int v, const int w) -> ll { return a[u] * v + b[v] * w + c[w] * u; }; auto g = [h, nc](const int u, const int v) -> ll { int l = 0, r = nc; while (r - l >= 3) { int x1 = l + (r - l) / 3; int x2 = r - (r - l) / 3; if (h(u, v, x1) >= h(u, v, x2)) r = x2; else l = x1; } ll ret = -INF; rep(i, l, r + 1) ret = max(ret, h(u, v, i)); return ret; }; auto f = [g, nb](const int u) -> ll { int l = 0, r = nb; while (r - l >= 3) { int x1 = l + (r - l) / 3; int x2 = r - (r - l) / 3; if (g(u, x1) >= g(u, x2)) r = x2; else l = x1; } ll ret = -INF; rep(i, l, r + 1) ret = max(ret, g(u, i)); return ret; }; ll ans = 0; rep(i, 0, na + 1) ans = max(ans, f(i)); cout << ans << endl; }