結果
問題 |
No.2495 Three Sets
|
ユーザー |
|
提出日時 | 2023-10-12 18:06:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 490 ms / 3,000 ms |
コード長 | 1,007 bytes |
コンパイル時間 | 3,701 ms |
コンパイル使用メモリ | 251,364 KB |
最終ジャッジ日時 | 2025-02-17 06:51:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using mint = atcoder::modint998244353; int main(){ int na,nb,nc; cin>>na>>nb>>nc; vector<int> a(na),b(nb),c(nc); rep(i,na) cin>>a.at(i); rep(i,nb) cin>>b.at(i); rep(i,nc) cin>>c.at(i); const ll shf=3005; vector<ll> ra(shf*2),rb(shf*2),rc(shf*2); rep(i,na) ra.at(a.at(i)+shf)++; rep(i,nb) rb.at(b.at(i)+shf)++; rep(i,nc) rc.at(c.at(i)+shf)++; vector<ll> sma(shf*2+1),csa(shf*2+1); for(int i=shf*2-1;i>=0;i--){ sma.at(i)=sma.at(i+1)+ra.at(i)*(i-shf); csa.at(i)=csa.at(i+1)+ra.at(i); } ll ans=0; ll smb=0,bb=0; for(int lb=shf*2-1;lb>=0;lb--){ ll smc=0,cc=0; for(int lc=shf*2-1;lc>=0;lc--){ int d; if(bb==0) d=-shf; else d=clamp(-smc/bb,-shf,shf); ll tmp=sma.at(d+shf)*bb+smb*cc+smc*csa.at(d+shf); ans=max(ans,tmp); smc+=rc.at(lc)*(lc-shf); cc+=rc.at(lc); } smb+=rb.at(lb)*(lb-shf); bb+=rb.at(lb); } cout<<ans<<endl; }