結果
問題 | No.2495 Three Sets |
ユーザー | a_s_k |
提出日時 | 2023-11-15 14:24:40 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 390 ms / 3,000 ms |
コード長 | 1,952 bytes |
コンパイル時間 | 2,428 ms |
コンパイル使用メモリ | 209,336 KB |
実行使用メモリ | 8,720 KB |
最終ジャッジ日時 | 2024-09-26 04:36:11 |
合計ジャッジ時間 | 4,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 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 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 74 ms
5,632 KB |
testcase_14 | AC | 171 ms
7,472 KB |
testcase_15 | AC | 68 ms
5,628 KB |
testcase_16 | AC | 385 ms
8,720 KB |
testcase_17 | AC | 390 ms
8,720 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 93 ms
8,716 KB |
testcase_20 | AC | 83 ms
8,720 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; } 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; rep(i, 0, A + 1) { 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)); } /*rep(j, 0, B + 1) { ans=max(ans,g(i,j)); cout<<g(i,j)<<endl; } cout<<endl;*/ } cout << ans << endl; }