結果

問題 No.2495 Three Sets
ユーザー KudeKude
提出日時 2023-10-06 22:36:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,942 bytes
コンパイル時間 3,007 ms
コンパイル使用メモリ 268,036 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-10-06 22:36:45
合計ジャッジ時間 12,259 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
4,376 KB
testcase_01 AC 278 ms
4,376 KB
testcase_02 AC 402 ms
4,376 KB
testcase_03 AC 276 ms
4,376 KB
testcase_04 AC 268 ms
4,376 KB
testcase_05 AC 271 ms
4,376 KB
testcase_06 AC 453 ms
4,380 KB
testcase_07 AC 426 ms
4,376 KB
testcase_08 AC 469 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 473 ms
4,376 KB
testcase_12 AC 467 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 51 ms
4,376 KB
testcase_19 AC 75 ms
4,380 KB
testcase_20 AC 523 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

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];
  constexpr int B = 3010;
  static int cnt[3][2 * B + 1];
  static int cacc[3][2 * B + 2];
  static ll s[3][2 * B + 2];
  rep(i, 3) {
    rep(j, n[i]) {
      int x;
      cin >> x;
      cnt[i][B + x]++;
    }
    rep(j, 2 * B + 1) {
      cacc[i][j + 1] = cacc[i][j] + cnt[i][j];
      s[i][j + 1] = s[i][j] + cnt[i][j] * (j - B);
    }
  }
  ll ans = 0;
  constexpr int INF = 1001001001;
  for (int v0 = -B; v0 <= B + 1; v0++) for (int v2 = -B; v2 <= B + 1; v2++) {
    ll s0 = s[0][B + B + 1] - s[0][B + v0];
    int c0 = cacc[0][B + B + 1] - cacc[0][B + v0];
    ll s2 = s[2][B + B + 1] - s[2][B + v2];
    int c2 = cacc[2][B + B + 1] - cacc[2][B + v2];
    auto flr = [&](ll x, int y) {
      if (x >= 0) return x / y;
      else return -((-x + y - 1) / y);
    };
    ll v1_ll = [&]() -> ll {
      if (c2 == 0) {
        return s0 > 0 ? -INF : INF;
      }
      return flr(-s0, c2);
    }();
    int v1 = clamp<ll>(v1_ll, -B, B + 1);
    ll s1 = s[1][B + B + 1] - s[1][B + v1];
    int c1 = cacc[1][B + B + 1] - cacc[1][B + v1];
    chmax(ans, s0 * c1 + s1 * c2 + s2 * c0);
  }
  cout << ans << '\n';
}
0