結果
問題 | No.2495 Three Sets |
ユーザー | a_s_k |
提出日時 | 2023-11-15 14:32:21 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,193 bytes |
コンパイル時間 | 2,208 ms |
コンパイル使用メモリ | 208,120 KB |
実行使用メモリ | 8,852 KB |
最終ジャッジ日時 | 2024-09-26 04:36:37 |
合計ジャッジ時間 | 3,699 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 37 ms
5,632 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 86 ms
8,724 KB |
testcase_20 | AC | 79 ms
8,724 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; using ll = long long; #define rep(i, m, n) for (ll i = m; i < n; i++) #define Endl endl vector<ll> sa, sb, sc; ll A, B, C; ll f(ll s, ll t, ll u) { return sa[s] * t + sb[t] * u + sc[u] * s; } ll g(ll i, ll j) { ll sub = -1e18; if (f(i, j, C - 1) <= f(i, j, C)) sub = max(sub, f(i, j, C)); else if (f(i, j, 0) > f(i, j, 1)) sub = max(sub, f(i, j, 0)); else { ll l = 0; ll r = C - 1; while (r - l > 1) { ll search = l + (r - l) / 2; if (f(i, j, search) <= f(i, j, search + 1)) l = search; else r = search; } sub = max(sub, f(i, j, r)); } return sub; } ll h(ll i) { ll ans=-1e18; if (g(i, 0) > g(i, 1)) ans = max(ans, g(i, 0)); else if (g(i, B - 1) < g(i, B)) ans = max(ans, g(i, B)); else { ll l = 0; ll r = B - 1; while (r - l > 1) { ll search = l + (r - l) / 2; if (g(i, search) <= g(i, search + 1)) l = search; else r = search; } ans = max(ans, g(i, r)); } return ans; } int main() { cin >> A >> B >> C; vector<ll> a(A), b(B), c(C); rep(i, 0, A) cin >> a[i]; rep(i, 0, B) cin >> b[i]; rep(i, 0, C) cin >> c[i]; sort(a.begin(), a.end()); sort(b.begin(), b.end()); sort(c.begin(), c.end()); reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); reverse(c.begin(), c.end()); sa.push_back(0); sb.push_back(0); sc.push_back(0); rep(i, 0, A) { sa.push_back(sa[i] + a[i]); } rep(i, 0, B) { sb.push_back(sb[i] + b[i]); } rep(i, 0, C) { sc.push_back(sc[i] + c[i]); } ll ans = -1e18; if(h(0)>h(1))ans=max(ans,h(0)); else if(h(A-1)<=h(A))ans=max(ans,h(A)); else { ll l=0; ll r=A-1; while(r-l>1){ ll search=l+(r-l)/2; if(h(search)<=h(search+1))l=search; else r=search; } ans=max(ans,h(r)); } cout << ans << endl; }