結果

問題 No.2495 Three Sets
ユーザー KudeKude
提出日時 2023-10-06 22:17:50
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,647 bytes
コンパイル時間 3,620 ms
コンパイル使用メモリ 276,768 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2023-10-06 22:17:59
合計ジャッジ時間 8,440 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 9 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 12 ms
4,380 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n[3];
  rep(i, 3) cin >> n[i];
  VL a[3];
  rep(i, 3) {
    a[i].resize(n[i]);
    rep(j, n[i]) cin >> a[i][j];
    sort(all(a[i]));
  }
  VL s[3];
  rep(i, 3) {
    s[i].resize(n[i] + 1);
    rep(j, n[i]) s[i][j+1] = s[i][j] + a[i][j];
  }
  ll ans = 0;
  constexpr int INF = 1001001001;
  rep(c0, n[0] + 1) rep(c2, n[2] + 1) {
    ll s0 = s[0][n[0]] - s[0][n[0] - c0];
    ll s2 = s[2][n[2]] - s[2][n[2] - c2];
    auto flr = [&](ll x, int y) {
      if (x >= 0) return x / y;
      else return -((-x + y - 1) / y);
    };
    ll v1 = [&]() -> ll {
      if (c2 == 0) {
        return s0 > 0 ? -INF : INF;
      }
      return flr(-s0, c2);
    }();
    int i1 = upper_bound(all(a[1]), v1) - a[1].begin();
    int c1 = n[1] - i1;
    ll s1 = s[1][n[1]] - s[1][n[1] - c1];
    chmax(ans, s0 * c1 + s1 * c2 + s2 * c0);
  }
  cout << ans << '\n';
}
0