結果
問題 |
No.2495 Three Sets
|
ユーザー |
|
提出日時 | 2023-10-06 22:30:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,536 bytes |
コンパイル時間 | 3,633 ms |
コンパイル使用メモリ | 258,036 KB |
最終ジャッジ日時 | 2025-02-17 05:18:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 4 |
ソースコード
#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); sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(c.begin(),c.end()); ll ans=0; rep(dd,3){ ll sma=0,smb=0,smc=0; ll ca=0,cb=0,cc=0; priority_queue<ll> pa,pb,pc; rep(i,na){ if(dd==0&&a.at(i)>0){ sma+=a.at(i); ca++; }else{ pa.push(a.at(i)); } } rep(i,nb){ if(dd==1&&b.at(i)>0){ smb+=b.at(i); cb++; }else{ pb.push(b.at(i)); } } rep(i,nc){ if(dd==2&&c.at(i)>0){ smc+=c.at(i); cc++; }else{ pc.push(c.at(i)); } } while(!pa.empty()||!pb.empty()||!pc.empty()){ ll ndf=0; int d=-1; if(!pa.empty()){ ll ad=pa.top(); ll df=smc+cb*ad; if(ndf<df){ ndf=df; d=0; } } if(!pb.empty()){ ll ad=pb.top(); ll df=sma+cc*ad; if(ndf<df){ ndf=df; d=1; } } if(!pc.empty()){ ll ad=pc.top(); ll df=smb+ca*ad; if(ndf<df){ ndf=df; d=2; } } if(ndf==0) break; if(d==0){ ll ad=pa.top(); pa.pop(); sma+=ad; ca++; }else if(d==1){ ll ad=pb.top(); pb.pop(); smb+=ad; cb++; }else{ ll ad=pc.top(); pc.pop(); smc+=ad; cc++; } } ans=max(ans,sma*cb+smb*cc+smc*ca); } cout<<ans<<endl; }