結果

問題 No.2495 Three Sets
ユーザー cho435cho435
提出日時 2023-10-12 18:06:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 580 ms / 3,000 ms
コード長 1,007 bytes
コンパイル時間 4,398 ms
コンパイル使用メモリ 259,724 KB
実行使用メモリ 4,524 KB
最終ジャッジ日時 2023-10-12 18:06:31
合計ジャッジ時間 14,210 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 290 ms
4,352 KB
testcase_01 AC 304 ms
4,348 KB
testcase_02 AC 433 ms
4,352 KB
testcase_03 AC 295 ms
4,352 KB
testcase_04 AC 294 ms
4,348 KB
testcase_05 AC 294 ms
4,352 KB
testcase_06 AC 321 ms
4,352 KB
testcase_07 AC 471 ms
4,352 KB
testcase_08 AC 459 ms
4,356 KB
testcase_09 AC 296 ms
4,352 KB
testcase_10 AC 296 ms
4,372 KB
testcase_11 AC 484 ms
4,348 KB
testcase_12 AC 483 ms
4,348 KB
testcase_13 AC 509 ms
4,348 KB
testcase_14 AC 533 ms
4,348 KB
testcase_15 AC 514 ms
4,372 KB
testcase_16 AC 580 ms
4,388 KB
testcase_17 AC 552 ms
4,520 KB
testcase_18 AC 98 ms
4,352 KB
testcase_19 AC 175 ms
4,524 KB
testcase_20 AC 550 ms
4,456 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);
	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;
}
0