結果

問題 No.2495 Three Sets
ユーザー KumaTachiRenKumaTachiRen
提出日時 2023-10-07 12:02:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,553 ms / 3,000 ms
コード長 1,540 bytes
コンパイル時間 4,635 ms
コンパイル使用メモリ 264,908 KB
実行使用メモリ 12,716 KB
最終ジャッジ日時 2023-10-07 12:03:10
合計ジャッジ時間 13,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 AC 226 ms
6,408 KB
testcase_14 AC 709 ms
9,524 KB
testcase_15 AC 251 ms
7,196 KB
testcase_16 AC 1,552 ms
12,532 KB
testcase_17 AC 1,553 ms
12,400 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1,522 ms
12,528 KB
testcase_20 AC 1,514 ms
12,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0