結果
問題 | No.2495 Three Sets |
ユーザー |
|
提出日時 | 2023-09-03 12:24:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 517 ms / 3,000 ms |
コード長 | 1,305 bytes |
コンパイル時間 | 4,059 ms |
コンパイル使用メモリ | 252,416 KB |
最終ジャッジ日時 | 2025-02-16 18:23:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)++)using ll = long long;using P = pair<ll, ll>;const int A_MAX = 3e3;ll ceil(ll a, ll b) { return a > 0 ? (a - 1) / b + 1 : a / b; }int main() {int na, nb, nc;cin >> na >> nb >> nc;auto read = [](const int n) {vector<ll> cnt(A_MAX * 2 + 1, 0);rep(i, 0, n) {int x;cin >> x;cnt[x + A_MAX]++;}vector<P> ret(A_MAX * 2 + 1);ll c = 0, s = 0;for (ll x = A_MAX; x >= -A_MAX; x--) {c += cnt[x + A_MAX];s += cnt[x + A_MAX] * x;ret[x + A_MAX] = P(c, s);}return ret;};auto a = read(na);auto b = read(nb);auto c = read(nc);ll ans = 0;for (auto q : b) {for (auto r : c) {if (q.first == 0) {ans = max(ans, max(0LL, na * r.second) + q.second * r.first);} else {ll x = ceil(-r.second, q.first);P p = x > A_MAX ? P(0, 0) : a[max(0LL, x + A_MAX)];ans = max(ans, p.second * q.first + q.second * r.first + r.second * p.first);}}}cout << ans << endl;}