結果

問題 No.2495 Three Sets
ユーザー cho435cho435
提出日時 2023-10-06 22:30:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,536 bytes
コンパイル時間 4,736 ms
コンパイル使用メモリ 265,488 KB
実行使用メモリ 7,712 KB
最終ジャッジ日時 2023-10-06 22:30:45
合計ジャッジ時間 6,161 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 54 ms
5,264 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 141 ms
7,428 KB
testcase_17 AC 140 ms
7,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 93 ms
7,712 KB
testcase_20 AC 107 ms
6,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0