結果
問題 | No.2495 Three Sets |
ユーザー | Kude |
提出日時 | 2023-10-06 22:36:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,942 bytes |
コンパイル時間 | 3,020 ms |
コンパイル使用メモリ | 271,384 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-26 16:41:34 |
合計ジャッジ時間 | 12,019 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 7 |
ソースコード
#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';}